Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dialog box choice stuff (mega-PR lol) #49

Merged
merged 72 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
fe8915f
add custom container class (editor won't open anymore lol)
Lamby777 Dec 5, 2023
f5577ca
fixed dialog choice drawing crash
Lamby777 Jan 5, 2024
b979331
use `Vector2::ZERO` where appropriate
Lamby777 Jan 5, 2024
7f7f55b
literally nothing important
Lamby777 Jan 5, 2024
f34bcd2
no errors (again...?)
Lamby777 Jan 8, 2024
af7fb34
tween method uses `&self`
Lamby777 Jan 8, 2024
b40f53c
tween txt label instead of container
Lamby777 Jan 10, 2024
b4f670a
use `IMarginContainer` instead of `IContainer`
Lamby777 Jan 12, 2024
4381690
dchoice constructor refactors
Lamby777 Jan 12, 2024
d6072fa
constructor fn moved into impl
Lamby777 Jan 12, 2024
6b407d3
`alloc_gd` -> `new_alloc`
Lamby777 Jan 12, 2024
fa59c45
moved responsibility of tweening dbox down into `End` variant only
Lamby777 Jan 12, 2024
669dbff
`self.active` guard clause
Lamby777 Jan 12, 2024
b15e463
finished `listvec`
Lamby777 Jan 12, 2024
5c0f9c9
choicelist `process_input` method passes off work to listvec methods
Lamby777 Jan 12, 2024
602bc77
bye bye :D
Lamby777 Jan 12, 2024
4c4bedd
byebye pt. 2
Lamby777 Jan 12, 2024
b7b4078
add `ChoiceList` type alias
Lamby777 Jan 12, 2024
25d1fe4
impl default for listvec
Lamby777 Jan 12, 2024
0a9a8c0
use `process_input` fn instead of method
Lamby777 Jan 12, 2024
96cb8b9
impl `Default` the long way (seriously?)
Lamby777 Jan 12, 2024
7d26018
constructors for new choicelist struct
Lamby777 Jan 12, 2024
e562fa0
into the spaghettiverse
Lamby777 Jan 12, 2024
688038c
fix handlers for battle engine choicelist
Lamby777 Jan 12, 2024
f4e6382
finished listvec refactors
Lamby777 Jan 12, 2024
1c704ab
add todo for inherent types later
Lamby777 Jan 12, 2024
9523f6e
listvec replaces selected_choice (+ cleanup)
Lamby777 Jan 12, 2024
6e3d4f5
no timer var
Lamby777 Jan 12, 2024
119436b
disperse `choice.rs` :)
Lamby777 Jan 12, 2024
de93e49
replaces listvec inner vector on recrating nodes
Lamby777 Jan 16, 2024
d178fdf
remove unused `selected_pair` method
Lamby777 Jan 16, 2024
1d1bc2f
`ListVec` derefs to `Vec`
Lamby777 Jan 16, 2024
5aaad8a
remove `choice_labels` method in favor of iterating over `choices` pr…
Lamby777 Jan 16, 2024
d9fe2ba
rm top-level `Speaker::*` and `Metaline::*` imports
Lamby777 Jan 16, 2024
f995cd9
a bunch of rename/refactor stuff
Lamby777 Jan 16, 2024
321bad9
add `is_on_last_page` method
Lamby777 Jan 16, 2024
f6766c6
split out "accept" stuff from `input` handler
Lamby777 Jan 16, 2024
3000ff9
add `current_ix_end` method
Lamby777 Jan 16, 2024
7fe2efc
YAGNI <3
Lamby777 Jan 16, 2024
6281d64
Revert "remove unused `selected_pair` method"
Lamby777 Jan 16, 2024
56d1fd0
extract dialogical label from ix
Lamby777 Jan 16, 2024
ad3d22d
added `run_label` method
Lamby777 Jan 16, 2024
3421753
end interaction if no label
Lamby777 Jan 16, 2024
00414c2
left/right selection of dialog options
Lamby777 Jan 16, 2024
ba9ceeb
pre `on_picked` migration
Lamby777 Jan 16, 2024
e94808d
`ListVec` pick handler now also passes index (+ added type aliases)
Lamby777 Jan 16, 2024
0a307d6
fix incorrect panic message
Lamby777 Jan 16, 2024
2e16d2e
rm handler types
Lamby777 Jan 16, 2024
b9adfd6
remove `ChoiceList`
Lamby777 Jan 16, 2024
a06598b
rename some stuff (mainly `ListVec` -> `Wrapped`)
Lamby777 Jan 16, 2024
07db06f
one `process_input` function for all directions
Lamby777 Jan 16, 2024
49bb8d9
combine `walk` and `offset_by` methods
Lamby777 Jan 16, 2024
6efed99
rename entire module
Lamby777 Jan 16, 2024
65b27f6
combine `Next` and `Prev` variants + rm unused vec parameter in `proc…
Lamby777 Jan 16, 2024
9b64224
fix stash merge conflict
Lamby777 Jan 16, 2024
12cc3e6
rm `next` and `prev` methods (at least for now)
Lamby777 Jan 16, 2024
aefc0ef
match on list action in `battle/mod.rs`
Lamby777 Jan 16, 2024
4258a98
add `pick_v` method
Lamby777 Jan 16, 2024
325a894
`pick` -> `pick_iv` and `pick_v` -> `pick`
Lamby777 Jan 16, 2024
794bf8d
match for main menu as well (+ a few refactors)
Lamby777 Jan 16, 2024
de74d04
moved old handler code into `match` body for dbox
Lamby777 Jan 16, 2024
df2fce9
move dialog choice stuff into separate fn
Lamby777 Jan 16, 2024
4bc291f
refactor: pass picked iv through `Pick` variant
Lamby777 Jan 16, 2024
c8b327e
goto label looks up ix id
Lamby777 Jan 16, 2024
10f6a9e
refactor wavy text stuff
Lamby777 Jan 16, 2024
d6da1ca
`Walk` variant passes old and new values like it used to be
Lamby777 Jan 16, 2024
e684dd3
fix tween panic
Lamby777 Jan 16, 2024
d8f00a9
uses correct constants for dbox choice tweening
Lamby777 Jan 17, 2024
86964bc
wavy text for dbox selection
Lamby777 Jan 17, 2024
2fbcfac
choices tween back down after selection confirmed
Lamby777 Jan 17, 2024
f57bba1
rm up/down prints + bruh moment
Lamby777 Jan 17, 2024
075d0c4
split bbcode "prefix" code to separate function + add unit test for it
Lamby777 Jan 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions pets-gd/scenes/dialogchoice.tscn
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
[gd_scene format=3 uid="uid://ckyanktf41aox"]

[node name="DChoice" type="DChoice"]
offset_right = 40.0
offset_bottom = 40.0
offset_right = 200.0
offset_bottom = 200.0

[node name="Label" type="RichTextLabel" parent="."]
layout_mode = 2
size_flags_vertical = 8
theme_override_colors/default_color = Color(0.803922, 0.839216, 0.956863, 1)
theme_override_font_sizes/normal_font_size = 56
bbcode_enabled = true
text = "Amogus"
text = "Sample Text Words Words More Words"
fit_content = true
scroll_active = false
autowrap_mode = 0
48 changes: 32 additions & 16 deletions pets-lib/src/battle/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ struct BattleEngine {
#[base]
node: Base<Node2D>,

choices: ChoiceList<BattleChoice, RichTextLabel>,
choices: Wrapped<(BattleChoice, Gd<RichTextLabel>)>,
state: BattleState,
}

Expand Down Expand Up @@ -96,26 +96,42 @@ fn tween_choice_to(is_picked: bool, node: Gd<RichTextLabel>) {
#[godot_api]
impl INode2D for BattleEngine {
fn ready(&mut self) {
use BattleChoice::*;

// The node that contains the text labels below
let cont = self.base().get_node_as("%Choices");

self.choices = ChoiceList::from_children_of(cont, tween_choice_to, |choice| {
// call different functions depending on the choice
match choice {
Attack => todo!(),
Skills => todo!(),
Items => todo!(),
Run => {
// TODO roll, don't always succeed
change_scene!("world");
}
}
});
use crate::wrapped::from_children_of;
self.choices = from_children_of(cont);
}

fn process(&mut self, _delta: f64) {
self.choices.process_input();
use crate::wrapped::*;
let action = process_input(&mut self.choices, ListDir::TopToBottom);

use ListOperation::*;
match action {
Walk(old, (_, new_node)) => {
if let Some((_, old_node)) = old {
tween_choice_to(false, old_node.clone());
}

tween_choice_to(true, new_node.clone());
}

Pick(_, (choice, _)) => {
// call different functions depending on the choice
use BattleChoice::*;
match choice {
Attack => todo!(),
Skills => todo!(),
Items => todo!(),
Run => {
// TODO roll, don't always succeed
change_scene!("world");
}
}
}

Nothing => {}
}
}
}
4 changes: 2 additions & 2 deletions pets-lib/src/battle/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl BattleIcon {
self.velocity *= self.friction;

// check inputs
let mut input_vector = Vector2::new(0.0, 0.0);
let mut input_vector = Vector2::ZERO;
for (k, v) in BATTLE_DIRECTIONS.iter() {
if input.is_action_pressed(k.clone()) {
input_vector += *v;
Expand Down Expand Up @@ -79,7 +79,7 @@ impl INode2D for BattleIcon {
speed: 400.0,
acceleration: 80.0,
friction: 0.96,
velocity: Vector2::new(0.0, 0.0),
velocity: Vector2::ZERO,
}
}

Expand Down
112 changes: 0 additions & 112 deletions pets-lib/src/choicelist.rs

This file was deleted.

13 changes: 8 additions & 5 deletions pets-lib/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//! All the "important" constants for configuring
//! how the game works. Tinker all you want. Go nuts. :)
//!
use godot::engine::tween::TransitionType;

pub mod playercb {
// Movement physics stuff
Expand All @@ -14,7 +15,7 @@ pub mod playercb {
}

pub mod dialogue {
use godot::engine::tween::TransitionType;
use super::*;

pub const NARRATOR_DISPLAYNAME: &str = "";
pub const UNKNOWN_DISPLAYNAME: &str = "???";
Expand All @@ -29,16 +30,18 @@ pub mod dialogue {
/// to avoid the glow effect from showing while it's not active
pub const DBOX_Y_BELOW_VIEWPORT: f32 = 20.0;

// pub const DBOX_CHOICE_TWEEN_TIME: f64 = DBOX_TWEEN_TIME;
// pub const DBOX_CHOICE_TWEEN_TRANS: TransitionType = DBOX_TWEEN_TRANS;
pub const DBOX_CHOICE_TWEEN_TIME: f64 = main_menu::MENU_TWEEN_TIME;
pub const DBOX_CHOICE_TWEEN_TRANS: TransitionType = DBOX_TWEEN_TRANS;
pub const DBOX_CHOICE_HEIGHT: f32 = 60.0;
pub const DBOX_CHOICE_WAVE_TIME: f64 = 0.1;

pub const DBOX_SELECTION_BBCODE: &str = "[wave amp=100 freq=-6]";
}

pub mod main_menu {
use godot::engine::tween::TransitionType;
use super::*;

pub const MENU_TWEEN_TIME: f64 = 0.1;
pub const MENU_TWEEN_TRANS: TransitionType = TransitionType::TRANS_QUAD;
pub const MENU_WAVE_BBCODE: &str = "[wave amp=100 freq=-6]";
pub const MENU_WAVE_BBCODE: &str = dialogue::DBOX_SELECTION_BBCODE;
}
86 changes: 0 additions & 86 deletions pets-lib/src/dialogue/dbox/choice.rs

This file was deleted.

Loading