44#include < process.h>
55
66static std::string file_name = " mods-settings.cwb" ;
7+ static const int MODS_PER_PAGE = 7 ;
78void * VTABLE[43 ];
89
910mod::ModWidget* mod::ModWidget::ctor (cube::Game* game, plasma::Node* node, plasma::Node* background, std::vector<DLL*>* mods)
@@ -50,7 +51,8 @@ void mod::ModWidget::MouseUp(cube::MouseButton mouse_button)
5051 this ->node ->SetVisibility (false );
5152 if (this ->changed )
5253 {
53- char * argument_list[] = { " cubeworld.exe" , NULL };
54+ // Restart the game
55+ char * argument_list[] = { (char *)" cubeworld.exe" , NULL };
5456 _execvp (" cubeworld.exe" , argument_list);
5557 }
5658 break ;
@@ -83,23 +85,14 @@ void mod::ModWidget::MouseUp(cube::MouseButton mouse_button)
8385
8486bool mod::ModWidget::NextPageAvailable ()
8587{
86- return (this ->page + 1 ) * 7 < this ->mods ->size ();
88+ return (this ->page + 1 ) * MODS_PER_PAGE < this ->mods ->size ();
8789}
8890
8991bool mod::ModWidget::PreviousPageAvailable ()
9092{
9193 return this ->page > 0 ;
9294}
9395
94- bool BtnIsHovered (FloatVector2* mouse_pos, float min_x, float max_x, int height)
95- {
96- if (mouse_pos->x < min_x || max_x <= mouse_pos->x || mouse_pos->y < height - 20 || height + 10 <= mouse_pos->y )
97- {
98- return false ;
99- }
100- return true ;
101- }
102-
10396void mod::ModWidget::Draw (ModWidget* widget)
10497{
10598 const static float text_size = 18 .0f ; // Original 18.0f
@@ -151,7 +144,7 @@ void mod::ModWidget::Draw(ModWidget* widget)
151144
152145 // Draw x to exit
153146 widget->SetTextPivot (plasma::TextPivot::Right);
154- if (BtnIsHovered (&mouse_pos, size.x - 30 , size. x - 10 , 20 + text_size ))
147+ if (plasma::Widget::IsSquareHovered (&mouse_pos, size.x - 30 , 20 , 20 , 30 ))
155148 {
156149 widget->SetTextColor (&hover_color);
157150 widget->hover_state = ModWidget::HoverState::Exit;
@@ -178,7 +171,7 @@ void mod::ModWidget::Draw(ModWidget* widget)
178171 }
179172
180173 int y_pos = (4 + 2 * y_count) * (10 + text_size);
181- if (BtnIsHovered (&mouse_pos, 0 , size.x , y_pos ))
174+ if (plasma::Widget::IsSquareHovered (&mouse_pos, 0 , y_pos - 20 , size.x , 30 ))
182175 {
183176 widget->SetTextColor (&hover_color);
184177 widget->hover_state = HoverState::Toggle;
@@ -204,7 +197,7 @@ void mod::ModWidget::Draw(ModWidget* widget)
204197 {
205198 widget->SetTextColor (&disabled_color);
206199 }
207- else if (BtnIsHovered (&mouse_pos, 20 , 20 + text_size, size.y - text_size))
200+ else if (plasma::Widget::IsSquareHovered (&mouse_pos, 20 , size.y - text_size - 20 , 20 , 30 ))
208201 {
209202 widget->hover_state = HoverState::Previous;
210203 widget->SetTextColor (&hover_color);
@@ -219,7 +212,7 @@ void mod::ModWidget::Draw(ModWidget* widget)
219212 {
220213 widget->SetTextColor (&disabled_color);
221214 }
222- else if (BtnIsHovered (&mouse_pos, size.x - text_size - 20 , size.x - 20 , size. y - text_size ))
215+ else if (plasma::Widget::IsSquareHovered (&mouse_pos, size.x - text_size - 20 , size.y - text_size - 20 , 20 , 30 ))
223216 {
224217 widget->hover_state = HoverState::Next;
225218 widget->SetTextColor (&hover_color);
@@ -229,7 +222,7 @@ void mod::ModWidget::Draw(ModWidget* widget)
229222 // Draw current page
230223 widget->SetTextColor (&text_color);
231224 widget->SetTextPivot (plasma::TextPivot::Center);
232- std::wstring page = std::to_wstring (widget->page + 1 ) + L" /" + std::to_wstring ((int )(widget->mods ->size () / 7 ) + 1 );
225+ std::wstring page = std::to_wstring (widget->page + 1 ) + L" /" + std::to_wstring ((int )(widget->mods ->size () / MODS_PER_PAGE ) + 1 );
233226 widget->DrawString (&pos, &page, size.x / 2 , size.y - text_size);
234227}
235228
0 commit comments