Cleanup / refractor
This commit is contained in:
+1
-5
@@ -182,13 +182,9 @@ struct App {
|
|||||||
current_scene_id = scene_id;
|
current_scene_id = scene_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
App(Vec2<float> size, const char *title, int anim_loading) {
|
App(Vec2<float> size, const char *title) {
|
||||||
window.update(size, title);
|
window.update(size, title);
|
||||||
#warning "Should try to center the loading image or scale it to fit the screen"
|
|
||||||
Scene *loading_scene = new Scene{};
|
Scene *loading_scene = new Scene{};
|
||||||
EImage *image = new EImage(anim_loading);
|
|
||||||
int image_id = element_pool.acquire(image);
|
|
||||||
loading_scene->add_element(image_id);
|
|
||||||
current_scene_id = scene_pool.acquire(loading_scene);
|
current_scene_id = scene_pool.acquire(loading_scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -353,18 +353,7 @@ static mrb_value app_run(mrb_state *mrb, mrb_value) {
|
|||||||
char *title = nullptr;
|
char *title = nullptr;
|
||||||
mrb_get_args(mrb, "iiz", &width, &height, &title);
|
mrb_get_args(mrb, "iiz", &width, &height, &title);
|
||||||
|
|
||||||
int loading_image = window.load_image("assets/images/menu_bg.png", 1.0f, true);
|
app_ = new app::App({(float)width, (float)height}, title);
|
||||||
|
|
||||||
Animation loading_animation = {
|
|
||||||
.frames = {loading_image},
|
|
||||||
.frame_rate = 1.0f,
|
|
||||||
.loop = false
|
|
||||||
};
|
|
||||||
|
|
||||||
int loading_animation_id = animation_pool.acquire(new Animation(loading_animation));
|
|
||||||
animation_pool.use(loading_animation_id);
|
|
||||||
|
|
||||||
app_ = new app::App({(float)width, (float)height}, title, loading_animation_id);
|
|
||||||
|
|
||||||
return mrb_nil_value();
|
return mrb_nil_value();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -363,17 +363,11 @@ bool Window::poll(Event &event) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_EVENT_KEY_DOWN:
|
case SDL_EVENT_KEY_DOWN:
|
||||||
#warning "This is a bit of a hack to prevent key down/up events from being generated when text input is active on certian keys," \
|
|
||||||
"but this list is not enough, need to look more into it"
|
|
||||||
if (text_input_active && sdl_event.key.key > '0' && sdl_event.key.key < 'z')
|
|
||||||
return false;
|
|
||||||
event.type = Event::KEY_DOWN;
|
event.type = Event::KEY_DOWN;
|
||||||
event.key.key = sdl_event.key.scancode;
|
event.key.key = sdl_event.key.scancode;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_EVENT_KEY_UP:
|
case SDL_EVENT_KEY_UP:
|
||||||
if (text_input_active && sdl_event.key.key > '0' && sdl_event.key.key < 'z')
|
|
||||||
return false;
|
|
||||||
event.type = Event::KEY_UP;
|
event.type = Event::KEY_UP;
|
||||||
event.key.key = sdl_event.key.scancode;
|
event.key.key = sdl_event.key.scancode;
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user