Skip to content

Commit 32306b6

Browse files
committed
update the code to compile with gdext 0.2.2 (holy fucking shit)
1 parent 7b5de9c commit 32306b6

28 files changed

+174
-208
lines changed

Diff for: pets-lib/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ chrono = { version = "0.4.38", features = ["serde"] }
1212
concat-idents = "1.1.5"
1313
derive_more = "0.99.17"
1414
derived-deref = "2.1.0"
15-
# godot = { version = "0.1.3", features = ["api-4-3", "experimental-threads", "experimental-godot-api"] }
15+
godot = { version = "0.2.2", features = ["api-4-3", "experimental-threads", "experimental-godot-api"] }
1616
# godot = { git = "https://github.com/godot-rust/gdext", rev = "c6d5205", features = ["api-4-3", "experimental-threads", "experimental-godot-api"] }
17-
godot = { git = "https://github.com/godot-rust/gdext", features = ["api-4-3", "experimental-threads", "experimental-godot-api"] }
17+
# godot = { git = "https://github.com/godot-rust/gdext", features = ["api-4-3", "experimental-threads", "experimental-godot-api"] }
1818
indoc = "2.0.4"
1919
libdx = "2.1.1"
2020
nodi = "1.0.0"

Diff for: pets-lib/src/battle/midi/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl Connection for GdW<MidiReceiver> {
5555
impl MidiReceiver {
5656
pub fn on_note_event(&mut self, on: bool, note: u8) {
5757
let signal = if on { "note_on" } else { "note_off" };
58-
self.base_mut().call_deferred("emit_signal".into(), &[
58+
self.base_mut().call_deferred("emit_signal", &[
5959
signal.to_variant(),
6060
note.to_variant(),
6161
]);

Diff for: pets-lib/src/battle/mod.rs

+17-17
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ impl BattleEngine {
131131

132132
let mut mana_bar =
133133
self.base().get_node_as::<ProgressBar>("%InfoBars/ManaBar");
134-
mana_bar.set("bar_value".into(), mana.unwrap_or(0).to_variant());
134+
mana_bar.set("bar_value", &mana.unwrap_or(0).to_variant());
135135

136136
let max_mana = battler.inherent_stats.max_mana;
137137
mana_bar.set_max(max_mana.unwrap_or(1).into());
@@ -147,15 +147,15 @@ impl BattleEngine {
147147
self.base().get_node_as::<ProgressBar>("%InfoBars/HPBar");
148148

149149
// go up instantly, but go down over time
150-
let hp_bar_value = hp_bar.get("bar_value".into()).to::<f64>();
150+
let hp_bar_value = hp_bar.get("bar_value").to::<f64>();
151151
let hp_bar_value = if hp >= hp_bar_value {
152152
hp
153153
} else {
154154
hp_bar_value - KARMA_STEP
155155
};
156156

157157
// update hp bar
158-
hp_bar.set("bar_value".into(), hp_bar_value.to_variant());
158+
hp_bar.set("bar_value", &hp_bar_value.to_variant());
159159

160160
let max_hp = battler.inherent_stats.max_hp;
161161
hp_bar.set_max(max_hp.into());
@@ -182,7 +182,7 @@ impl BattleEngine {
182182
/// slowly fade out the black rectangle over the battle scene
183183
#[func]
184184
pub fn animate_in(&mut self) {
185-
self.animator.set_assigned_animation("fade_in".into());
185+
self.animator.set_assigned_animation("fade_in");
186186
self.animator.play();
187187
}
188188

@@ -248,8 +248,8 @@ impl BattleEngine {
248248
self.base().get_node_as::<TextureRect>("%PortraitTexture");
249249

250250
let path = format!("res://assets/textures/portraits/{}.png", pchar);
251-
let texture = load::<Texture2D>(path);
252-
portrait.set_texture(texture);
251+
let texture = load::<Texture2D>(&path);
252+
portrait.set_texture(&texture);
253253
}
254254

255255
#[func]
@@ -298,10 +298,10 @@ impl BattleEngine {
298298
.expect("no skills menu scene exported")
299299
.instantiate_as::<PanelContainer>();
300300

301-
panel.set("battle_engine".into(), self.base().to_variant());
302-
cont.add_child(panel.clone());
301+
panel.set("battle_engine", &self.base().to_variant());
302+
cont.add_child(&panel);
303303

304-
let mut agent: Gd<ChoiceAgent> = panel.get("choice_agent".into()).to();
304+
let mut agent: Gd<ChoiceAgent> = panel.get("choice_agent").to();
305305
agent.bind_mut().enable();
306306

307307
self.other_choices = Some(agent);
@@ -310,7 +310,7 @@ impl BattleEngine {
310310
// animate slide the new menu up
311311
cont.get_node_as::<AnimationPlayer>("../AnimationPlayer")
312312
.play_ex()
313-
.name("margin_slide_up".into())
313+
.name("margin_slide_up")
314314
.done();
315315
}
316316

@@ -347,18 +347,18 @@ impl BattleEngine {
347347

348348
#[func]
349349
fn on_note_hit(&mut self) {
350-
self.click_status_txt.set_text("Hit!".into());
350+
self.click_status_txt.set_text("Hit!");
351351
self.clicksfx.play();
352352
}
353353

354354
#[func]
355355
fn on_note_flop(&mut self) {
356-
self.click_status_txt.set_text("Flop!".into());
356+
self.click_status_txt.set_text("Flop!");
357357
}
358358

359359
#[func]
360360
fn on_note_miss(&mut self) {
361-
self.click_status_txt.set_text("Miss!".into())
361+
self.click_status_txt.set_text("Miss!")
362362
}
363363

364364
// ------------------------------------------------------------
@@ -374,7 +374,7 @@ impl BattleEngine {
374374
let enemy_id = &enemy_data.borrow().id;
375375

376376
self.base()
377-
.get_node_as::<Node>(format!("Tactics/{}", enemy_id))
377+
.get_node_as::<Node>(&format!("Tactics/{}", enemy_id))
378378
.set_process_mode(ProcessMode::ALWAYS);
379379
}
380380
}
@@ -395,7 +395,7 @@ impl INode2D for BattleEngine {
395395
timer.start();
396396

397397
let callable = self.base().callable("on_karma");
398-
timer.connect("timeout".into(), callable);
398+
timer.connect("timeout", &callable);
399399

400400
self.karma_timer.init(timer.upcast());
401401
}
@@ -408,7 +408,7 @@ impl INode2D for BattleEngine {
408408
timer.start();
409409
let callable = self.base().callable("intro_over");
410410
timer
411-
.connect_ex("timeout".into(), callable)
411+
.connect_ex("timeout", &callable)
412412
.flags(ConnectFlags::ONE_SHOT.ord() as u32)
413413
.done();
414414
}
@@ -429,7 +429,7 @@ impl INode2D for BattleEngine {
429429
}
430430

431431
fn input(&mut self, event: Gd<InputEvent>) {
432-
if event.is_action_pressed("menu".into()) {
432+
if event.is_action_pressed("menu") {
433433
self.toggle_dualmenu();
434434
}
435435
}

Diff for: pets-lib/src/battle/player.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ impl BattleIcon {
8080

8181
// check inputs
8282
let mut input_vector = Vector2::ZERO;
83-
for (k, v) in BATTLE_DIRECTIONS.iter() {
84-
if input.is_action_pressed(k.clone()) {
83+
for (key, v) in BATTLE_DIRECTIONS.iter() {
84+
if input.is_action_pressed(key) {
8585
input_vector += *v;
8686
}
8787
}
@@ -99,7 +99,7 @@ impl BattleIcon {
9999

100100
#[func]
101101
fn on_hit(&mut self, mut bullet: Gd<Node2D>) {
102-
let dmg_ratio = bullet.get("damage_ratio".into()).to::<f64>();
102+
let dmg_ratio = bullet.get("damage_ratio").to::<f64>();
103103
let base_dmg = pcb().bind().battling[0]
104104
.borrow()
105105
.battler

Diff for: pets-lib/src/battle/rhythm.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,17 @@ impl BattleMusic {
9595
/// Called when the player successfully hits a note
9696
fn on_attack_hit(&mut self) {
9797
self.rhythm.reset();
98-
self.base_mut().emit_signal("note_hit".into(), &[]);
98+
self.base_mut().emit_signal("note_hit", &[]);
9999
}
100100

101101
fn on_attack_flop(&mut self) {
102102
self.on_attack_flop_or_miss();
103-
self.base_mut().emit_signal("note_flop".into(), &[]);
103+
self.base_mut().emit_signal("note_flop", &[]);
104104
}
105105

106106
fn on_attack_miss(&mut self) {
107107
self.on_attack_flop_or_miss();
108-
self.base_mut().emit_signal("note_miss".into(), &[]);
108+
self.base_mut().emit_signal("note_miss", &[]);
109109
}
110110

111111
fn on_attack_flop_or_miss(&mut self) {
@@ -210,7 +210,7 @@ impl IAudioStreamPlayer for BattleMusic {
210210
}
211211

212212
fn input(&mut self, event: Gd<InputEvent>) {
213-
if event.is_action_pressed("ui_accept".into()) {
213+
if event.is_action_pressed("ui_accept") {
214214
self.on_player_clicked();
215215
}
216216
}

Diff for: pets-lib/src/battle/skills/attack.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl AttackSkill {
4747
panic!("power should be `Some(1..=5)` or `None`");
4848
}
4949

50-
let adjective = tr(format!("SKILL_ATTACK_POWER_{}", self.power?));
50+
let adjective = tr(&format!("SKILL_ATTACK_POWER_{}", self.power?));
5151

5252
Some(tr_replace! {
5353
"SKILL_ATTACK_POWER_DESCRIBE";

Diff for: pets-lib/src/battle/skills/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub(crate) use recovery::{RecoverySkill, RecoveryType};
2525
pub(crate) use shields::ShieldSkill;
2626

2727
fn power_to_letter(power: u8) -> GString {
28-
tr(format!("SKILL_TIER_{}", power))
28+
tr(&format!("SKILL_TIER_{}", power))
2929
}
3030

3131
fn power_to_letter_pl(power: u8, plural: bool) -> GString {
@@ -135,6 +135,6 @@ impl Element {
135135
/// User-facing string for formatting the element of a skill
136136
/// Handles the "edge cases" of grammar like "Fuzz" => "Fuzzy"
137137
pub fn adjective(&self) -> GString {
138-
tr(format!("ELEMENT_ADJ_{:?}", self))
138+
tr(&format!("ELEMENT_ADJ_{:?}", self))
139139
}
140140
}

Diff for: pets-lib/src/battle/skills/status_effects.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ impl EffectAndChance {
2222
impl Describe for EffectAndChance {
2323
fn describe(&self) -> GString {
2424
let fx = self.effect.to_string();
25-
tr_replace! { self.chance.description_tr_template(); fx }.into()
25+
tr_replace! { &self.chance.description_tr_template(); fx }.into()
2626
}
2727
}
2828

Diff for: pets-lib/src/dialogue/dbox/dchoice.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub struct DChoice {
2626
impl DChoice {
2727
#[func]
2828
pub fn set_text_tr(&mut self, text: GString) {
29-
self.txt_label.set_text(tr(text));
29+
self.txt_label.set_text(&tr(text.arg()));
3030
}
3131

3232
/// tween the contained text label in/out of the window
@@ -55,9 +55,9 @@ impl DChoice {
5555
let scene = load::<PackedScene>("res://scenes/dialogchoice.tscn");
5656
let mut dchoice = scene.instantiate_as::<Self>();
5757

58-
dchoice.set_name(format!("Choice{}", i).into());
58+
dchoice.set_name(&format!("Choice{}", i));
5959

60-
dchoice.call_deferred("set_text_tr".into(), &[text.to_variant()]);
60+
dchoice.call_deferred("set_text_tr", &[text.to_variant()]);
6161
// dchoice.bind_mut().set_text_tr(text.into());
6262

6363
dchoice

Diff for: pets-lib/src/dialogue/dbox/mod.rs

+17-24
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl DialogBox {
6969
#[func]
7070
pub fn singleton() -> Gd<Self> {
7171
let path = format!("{}/{}", UI_LAYER_NAME, DBOX_NODE_NAME);
72-
World::singleton().get_node_as::<DialogBox>(path)
72+
World::singleton().get_node_as::<DialogBox>(&path)
7373
}
7474

7575
#[func]
@@ -93,8 +93,8 @@ impl DialogBox {
9393
.then(|| self.translated_message())
9494
.unwrap_or("".into());
9595

96-
self.spk_txt.set_text(spk);
97-
self.msg_txt.set_text(msg);
96+
self.spk_txt.set_text(&spk);
97+
self.msg_txt.set_text(&msg);
9898

9999
self.msg_txt.set_visible_characters(0);
100100
self.text_visibility_timer.start();
@@ -136,12 +136,12 @@ impl DialogBox {
136136
/// First processes placeholders, then translation keys.
137137
fn translated_speaker(&self) -> GString {
138138
// Unknown => tr("DG_SPK_UNKNOWN"),
139-
tr(placeholders::process_placeholders(&self.speaker))
139+
tr(&placeholders::process_placeholders(&self.speaker))
140140
}
141141

142142
fn translated_message(&self) -> GString {
143143
let content = self.message.clone();
144-
let content = tr(content).to_string();
144+
let content = tr(&content).to_string();
145145

146146
placeholders::process_placeholders(&content).into()
147147
}
@@ -168,8 +168,7 @@ impl DialogBox {
168168
}
169169

170170
fn on_confirm_next_page(&mut self) {
171-
self.base_mut()
172-
.emit_signal("accept".into(), &[(-1).to_variant()]);
171+
self.base_mut().emit_signal("accept", &[(-1).to_variant()]);
173172
}
174173

175174
#[func]
@@ -179,7 +178,7 @@ impl DialogBox {
179178
self.tween_choices_wave(false);
180179

181180
self.base_mut()
182-
.emit_signal("accept".into(), &[picked_i.to_variant()]);
181+
.emit_signal("accept", &[picked_i.to_variant()]);
183182
}
184183

185184
fn awaiting_choice(&self) -> bool {
@@ -199,10 +198,10 @@ impl DialogBox {
199198
let children = children_of_type::<DChoice, _>(&cont.clone());
200199

201200
for mut node in children {
202-
node.set_name("deleted".into());
201+
node.set_name("deleted");
203202
node.queue_free();
204203
ChoiceAgent::unbind_callables_for(&mut node);
205-
cont.remove_child(node);
204+
cont.remove_child(&node);
206205
}
207206
}
208207

@@ -219,7 +218,7 @@ impl DialogBox {
219218
.bind_mut()
220219
.bind_callables_for(&mut dchoice);
221220

222-
cont.add_child(dchoice.clone());
221+
cont.add_child(&dchoice);
223222

224223
// put label below the window
225224
dchoice.bind_mut().put_label_under();
@@ -243,10 +242,10 @@ impl DialogBox {
243242
let own_path = node.get_path();
244243
let prev_path = previous.get_path();
245244

246-
previous.set_focus_next(own_path.clone());
247-
previous.set_focus_neighbor(Side::RIGHT, own_path);
248-
node.set_focus_previous(prev_path.clone());
249-
node.set_focus_neighbor(Side::LEFT, prev_path);
245+
previous.set_focus_next(&own_path);
246+
previous.set_focus_neighbor(Side::RIGHT, &own_path);
247+
node.set_focus_previous(&prev_path);
248+
node.set_focus_neighbor(Side::LEFT, &prev_path);
250249

251250
previous = node;
252251
}
@@ -284,10 +283,7 @@ impl DialogBox {
284283

285284
// if tweening down, delete it after the tween
286285
if !up {
287-
tw.connect(
288-
"finished".into(),
289-
label.callable("queue_free"),
290-
);
286+
tw.connect("finished", &label.callable("queue_free"));
291287
}
292288
};
293289
});
@@ -312,10 +308,7 @@ impl IPanelContainer for DialogBox {
312308

313309
let mut timer = Timer::new_alloc();
314310
timer.set_wait_time(TEXT_VISIBILITY_DELAY);
315-
timer.connect(
316-
"timeout".into(),
317-
self.base().callable("text_visibility_tick"),
318-
);
311+
timer.connect("timeout", &self.base().callable("text_visibility_tick"));
319312
timer.set_one_shot(true);
320313
self.base_mut().add_child(&timer);
321314
self.text_visibility_timer.init(timer);
@@ -326,7 +319,7 @@ impl IPanelContainer for DialogBox {
326319
return;
327320
}
328321

329-
let confirming = event.is_action_pressed("ui_accept".into());
322+
let confirming = event.is_action_pressed("ui_accept");
330323
if confirming && !self.is_done_showing_text() {
331324
self.skip_text_visibility();
332325
return;

Diff for: pets-lib/src/dialogue/script.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ impl DialogueScript {
1313
#[func]
1414
pub fn new(script: Gd<GDScript>) -> Gd<Self> {
1515
let mut executor = DialogueScript::new_alloc();
16-
executor.set_script(script.to_variant());
16+
executor.set_script(&script.to_variant());
1717
executor
1818
}
1919

0 commit comments

Comments
 (0)