Some fixes
This commit is contained in:
parent
1c9069b5ce
commit
8e4b8fc37a
@ -97,12 +97,12 @@ namespace ui_scripting
|
||||
|
||||
float relative(float value)
|
||||
{
|
||||
return (value / 1920.f) * screen_max[0];
|
||||
return ceil((value / 1920.f) * screen_max[0]);
|
||||
}
|
||||
|
||||
int relative(int value)
|
||||
{
|
||||
return (int)(((float)value / 1920.f) * screen_max[0]);
|
||||
return (int)ceil(((float)value / 1920.f) * screen_max[0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -624,6 +624,16 @@ namespace ui_scripting::lua
|
||||
auto game_type = state.new_usertype<game>("game_");
|
||||
state["game"] = game();
|
||||
|
||||
game_type["getmenu"] = [](const game&, const sol::this_state s, const std::string& name)
|
||||
{
|
||||
if (menus.find(name) == menus.end())
|
||||
{
|
||||
return sol::lua_value{s, sol::lua_nil};
|
||||
}
|
||||
|
||||
return sol::lua_value{s, &menus[name]};
|
||||
};
|
||||
|
||||
game_type["getelement"] = [](const game&, const sol::this_state s, const std::string& value, const std::string& attribute)
|
||||
{
|
||||
for (const auto& element : elements)
|
||||
@ -716,7 +726,7 @@ namespace ui_scripting::lua
|
||||
|
||||
event event;
|
||||
event.element = menu;
|
||||
event.name = "close";
|
||||
event.name = "open";
|
||||
handler.dispatch(event);
|
||||
|
||||
menu->open();
|
||||
|
@ -23,17 +23,17 @@ namespace ui_scripting::lua::engine
|
||||
|
||||
int relative_mouse(int value)
|
||||
{
|
||||
return (int)(((float)value / screen_max[0]) * 1920.f);
|
||||
return (int)ceil(((float)value / screen_max[0]) * 1920.f);
|
||||
}
|
||||
|
||||
int relative(int value)
|
||||
{
|
||||
return (int)(((float)value / 1920.f) * screen_max[0]);
|
||||
return (int)ceil(((float)value / 1920.f) * screen_max[0]);
|
||||
}
|
||||
|
||||
float relative(float value)
|
||||
{
|
||||
return (value / 1920.f) * screen_max[0];
|
||||
return ceil((value / 1920.f) * screen_max[0]);
|
||||
}
|
||||
|
||||
bool point_in_rect(int px, int py, int x, int y, int w, int h)
|
||||
|
Loading…
Reference in New Issue
Block a user