Skip to content

Commit 87ca850

Browse files
committed
move functions to namespace
1 parent f272f28 commit 87ca850

File tree

6 files changed

+119
-118
lines changed

6 files changed

+119
-118
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
> [!TIP]
55
>
6-
> This mod is primarily intended for mobile users. But can be used on PC
6+
> This mod is primarily intended for mobile users, but supports all platforms.
77
88
This mod adds a scalable and moveable UI to the level editor with move, rotate, and flip buttons to help you save time when transforming objects in the level editor! You can find a button to quickly access this mod's settings in the editor pause menu.
99

@@ -15,14 +15,14 @@ In the mod's settings, you can customize button visuals and functionality.
1515
3. Press the center button to toggle the move units.
1616

1717
# Credits
18-
- **Cheeseworks** - For helping me make this mod possible since I barely understand some functionality to make things work
19-
- **CyanBoi** - For beta testing, finding bugs and giving me feedbacks
20-
- **iCreate Pro** - For inspiration on the Custom Move Button feature
18+
- **[Cheeseworks](https://gdbrowser.com/u/cheeseworks)** - For helping me make this mod possible since I barely understand some functionality to make things work
19+
- **[CyanBoi](https://gdbrowser.com/u/CyanBoi)** - For beta testing, finding bugs and giving me feedbacks
20+
- **[iCreate Pro](https://icreate.pro/)** - For inspiration on the Custom Move Button feature
2121

2222
# Previews
2323
![UI with button background](previews/preview-1.png)
2424
![UI without button background](previews/preview-2.png)
2525

2626
# Known Bugs
2727
- Buttons disappears whenever you copy + paste multiple objects. Appears again whenever you move your editor
28-
*(Best way to prevent this is enabling Button Presistent since I don't know how to fix this bug)*
28+
*(You can currently prevent this by enabling `Button Presistent` in the settings)*

about.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Quick Move Buttons
22

3-
> <cg>This mod is primarily intended for mobile users. But can be used on PC</c>
3+
> <cg>This mod is primarily intended for mobile users, but supports all platforms.</c>
44
55
This mod adds a scalable and moveable UI to the level editor with move, rotate, and flip buttons to help you save time when transforming objects in the level editor! You can find a button to quickly access this mod's settings in the editor pause menu.
66

@@ -22,4 +22,4 @@ In the mod's settings, you can customize button visuals and functionality.
2222

2323
# Known Bugs
2424
- Buttons disappears whenever you copy + paste multiple objects. Appears again whenever you move your editor
25-
*(Best way to prevent this is enabling Button Presistent since I don't know how to fix this bug)*
25+
*(You can currently prevent this by enabling `Button Presistent` in the settings)*

changelog.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# v1.0.3
2-
- Minor fixes
2+
- Code cleanup
3+
- Minor tweaks
34

45
# v1.0.2
56
- Code cleanup

mod.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"settings": {
3535
"scale-btns": {
3636
"name": "Button Scale",
37-
"description": "Change the scale of the transform buttons, <co>the draggable area will also be affected</co>. <cr>Must reopen the editor to take effect.</cr>",
37+
"description": "Change the scale of the transform buttons, <co>the draggable area will also be affected</co>. <cr>You must reopen the editor to take effect.</cr>",
3838
"type": "float",
3939
"default": 1,
4040
"min": 0.5,
@@ -58,7 +58,7 @@
5858
},
5959
"scale-bg": {
6060
"name": "Draggable Area Scale",
61-
"description": "Change the scale of the draggable area. <cg>Useful if you can't drag properly due to the area size.</cg> <cr>Must reopen the editor to take effect.</cr>",
61+
"description": "Change the scale of the draggable area. <cg>Useful if you can't drag properly due to the area size.</cg> <cr>You must reopen the editor to take effect.</cr>",
6262
"type": "int",
6363
"default": 130,
6464
"min": 130,
@@ -70,7 +70,7 @@
7070
},
7171
"visible-bg": {
7272
"name": "Show Button Background",
73-
"description": "Show the backgrounds of the transform buttons. <cr>Must reopen the editor to take effect.</cr>",
73+
"description": "Show the backgrounds of the transform buttons. <cr>You must reopen the editor to take effect.</cr>",
7474
"type": "bool",
7575
"default": false
7676
},
@@ -88,7 +88,7 @@
8888
},
8989
"presistent-btn": {
9090
"name": "Persistent Button",
91-
"description": "Always show the transform buttons, even when an object is not selected.",
91+
"description": "Always show the transform buttons, even when no objects are selected.",
9292
"type": "bool",
9393
"default": false
9494
}

src/QuickMove.hpp

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,107 @@ namespace quickmove {
2525
Left = 3,
2626
Right = 4
2727
};
28+
29+
// Returns the EditCommand based on object move size and direction
30+
EditCommand getEditCmd(MoveSize moveSize, MoveDirection moveDir) {
31+
switch (moveSize) {
32+
case MoveSize::Tiny:
33+
switch (moveDir) {
34+
case MoveDirection::Up: return EditCommand::TinyUp;
35+
case MoveDirection::Down: return EditCommand::TinyDown;
36+
case MoveDirection::Left: return EditCommand::TinyLeft;
37+
case MoveDirection::Right: return EditCommand::TinyRight;
38+
};
39+
break;
40+
41+
case MoveSize::Small:
42+
switch (moveDir) {
43+
case MoveDirection::Up: return EditCommand::SmallUp;
44+
case MoveDirection::Down: return EditCommand::SmallDown;
45+
case MoveDirection::Left: return EditCommand::SmallLeft;
46+
case MoveDirection::Right: return EditCommand::SmallRight;
47+
};
48+
break;
49+
50+
case MoveSize::Half:
51+
switch (moveDir) {
52+
case MoveDirection::Up: return EditCommand::HalfUp;
53+
case MoveDirection::Down: return EditCommand::HalfDown;
54+
case MoveDirection::Left: return EditCommand::HalfLeft;
55+
case MoveDirection::Right: return EditCommand::HalfRight;
56+
};
57+
break;
58+
59+
case MoveSize::Normal:
60+
switch (moveDir) {
61+
case MoveDirection::Up: return EditCommand::Up;
62+
case MoveDirection::Down: return EditCommand::Down;
63+
case MoveDirection::Left: return EditCommand::Left;
64+
case MoveDirection::Right: return EditCommand::Right;
65+
};
66+
break;
67+
68+
case MoveSize::Big:
69+
switch (moveDir) {
70+
case MoveDirection::Up: return EditCommand::BigUp;
71+
case MoveDirection::Down: return EditCommand::BigDown;
72+
case MoveDirection::Left: return EditCommand::BigLeft;
73+
case MoveDirection::Right: return EditCommand::BigRight;
74+
};
75+
break;
76+
77+
default:
78+
return EditCommand::SmallUp;
79+
};
80+
81+
return EditCommand::SmallUp;
82+
};
83+
84+
// Get the string name for a move size for debugging
85+
std::string getMoveSizeName(MoveSize moveSize) {
86+
switch (moveSize) {
87+
case MoveSize::Tiny:
88+
return "Tiny";
89+
90+
case MoveSize::Small:
91+
return "Small";
92+
93+
case MoveSize::Half:
94+
return "Half";
95+
96+
case MoveSize::Normal:
97+
return "Normal";
98+
99+
case MoveSize::Big:
100+
return "Big";
101+
102+
default:
103+
return "Small";
104+
};
105+
};
106+
107+
// Get the sprite name and scale for arrow icons based on move size
108+
std::pair<std::string, float> getMoveSizeIconInfo(MoveSize moveSize) {
109+
float defScale = 0.875f;
110+
111+
switch (moveSize) {
112+
case MoveSize::Tiny:
113+
return { "edit_upBtn_001.png", 0.625f };
114+
115+
case MoveSize::Small:
116+
return { "edit_upBtn_001.png", defScale };
117+
118+
case MoveSize::Half:
119+
return { "edit_upBtn5_001.png", defScale };
120+
121+
case MoveSize::Normal:
122+
return { "edit_upBtn2_001.png", defScale };
123+
124+
case MoveSize::Big:
125+
return { "edit_upBtn3_001.png", defScale };
126+
127+
default:
128+
return { "edit_upBtn_001.png", defScale };
129+
};
130+
};
28131
};

src/main.cpp

Lines changed: 3 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -16,109 +16,6 @@ using namespace quickmove;
1616
// it's modding time :3
1717
auto qmbMod = getMod();
1818

19-
// Returns the EditCommand based on object move size and direction
20-
EditCommand getEditCmd(MoveSize moveSize, MoveDirection moveDir) {
21-
switch (moveSize) {
22-
case MoveSize::Tiny:
23-
switch (moveDir) {
24-
case MoveDirection::Up: return EditCommand::TinyUp;
25-
case MoveDirection::Down: return EditCommand::TinyDown;
26-
case MoveDirection::Left: return EditCommand::TinyLeft;
27-
case MoveDirection::Right: return EditCommand::TinyRight;
28-
};
29-
break;
30-
31-
case MoveSize::Small:
32-
switch (moveDir) {
33-
case MoveDirection::Up: return EditCommand::SmallUp;
34-
case MoveDirection::Down: return EditCommand::SmallDown;
35-
case MoveDirection::Left: return EditCommand::SmallLeft;
36-
case MoveDirection::Right: return EditCommand::SmallRight;
37-
};
38-
break;
39-
40-
case MoveSize::Half:
41-
switch (moveDir) {
42-
case MoveDirection::Up: return EditCommand::HalfUp;
43-
case MoveDirection::Down: return EditCommand::HalfDown;
44-
case MoveDirection::Left: return EditCommand::HalfLeft;
45-
case MoveDirection::Right: return EditCommand::HalfRight;
46-
};
47-
break;
48-
49-
case MoveSize::Normal:
50-
switch (moveDir) {
51-
case MoveDirection::Up: return EditCommand::Up;
52-
case MoveDirection::Down: return EditCommand::Down;
53-
case MoveDirection::Left: return EditCommand::Left;
54-
case MoveDirection::Right: return EditCommand::Right;
55-
};
56-
break;
57-
58-
case MoveSize::Big:
59-
switch (moveDir) {
60-
case MoveDirection::Up: return EditCommand::BigUp;
61-
case MoveDirection::Down: return EditCommand::BigDown;
62-
case MoveDirection::Left: return EditCommand::BigLeft;
63-
case MoveDirection::Right: return EditCommand::BigRight;
64-
};
65-
break;
66-
67-
default:
68-
return EditCommand::SmallUp;
69-
};
70-
71-
return EditCommand::SmallUp;
72-
};
73-
74-
// Get the string name for a move size
75-
std::string getMoveSizeName(MoveSize moveSize) {
76-
switch (moveSize) {
77-
case MoveSize::Tiny:
78-
return "Tiny";
79-
80-
case MoveSize::Small:
81-
return "Small";
82-
83-
case MoveSize::Half:
84-
return "Half";
85-
86-
case MoveSize::Normal:
87-
return "Normal";
88-
89-
case MoveSize::Big:
90-
return "Big";
91-
92-
default:
93-
return "Small";
94-
};
95-
};
96-
97-
// Get the sprite name and scale for arrow icons based on move size
98-
std::pair<std::string, float> getMoveSizeIconInfo(MoveSize moveSize) {
99-
float defScale = 0.875f;
100-
101-
switch (moveSize) {
102-
case MoveSize::Tiny:
103-
return { "edit_upBtn_001.png", 0.625f };
104-
105-
case MoveSize::Small:
106-
return { "edit_upBtn_001.png", defScale };
107-
108-
case MoveSize::Half:
109-
return { "edit_upBtn5_001.png", defScale };
110-
111-
case MoveSize::Normal:
112-
return { "edit_upBtn2_001.png", defScale };
113-
114-
case MoveSize::Big:
115-
return { "edit_upBtn3_001.png", defScale };
116-
117-
default:
118-
return { "edit_upBtn_001.png", defScale };
119-
};
120-
};
121-
12219
class $modify(MyEditorUI, EditorUI) {
12320
struct Fields {
12421
MoveSize moveSize = MoveSize::Small;
@@ -460,12 +357,12 @@ class $modify(MyEditorUI, EditorUI) {
460357
// Initialize rotation buttons (will be updated when objects are selected)
461358
updateRotationButtons();
462359

463-
return true;
464-
465360
// shocking it aint spagetti code :D
466361
// see cheese i made u proud with my amazing dumb coding skills
467362

468363
// very proud :)
364+
365+
return true; // yay
469366
};
470367

471368
void showUI(bool show) {
@@ -530,8 +427,8 @@ class $modify(MyEditorUI, EditorUI) {
530427

531428
// i was gonna do if else statement but after learning about my c lessons in uni about switch statements, i use this :D
532429

430+
// Cycle through move sizes
533431
void onMoveSizeButton(CCObject*) {
534-
// Cycle through move sizes
535432
switch (m_fields->moveSize) {
536433
case MoveSize::Tiny:
537434
m_fields->moveSize = MoveSize::Small;

0 commit comments

Comments
 (0)