def main(): from rssim_core import Launcher from ui import WINDOW try: Launcher().run() except (VideoAdapterNotSupportedError, MonitorNotSupportedError, UpdateIncompatibleError, HackingDetectedError) as e: WINDOW.close() windll.user32.MessageBoxW(None, e.text, e.caption, 0x1000) except Exception: if not path.exists('logs'): mkdir('logs') crash_datetime = datetime.now() filename = 'logs/logs_{0}_{1:0>2}-{2:0>2}-{3:0>2}-{4:0>6}.crash'.format( str(crash_datetime.date()), crash_datetime.time().hour, crash_datetime.time().minute, crash_datetime.time().second, crash_datetime.time().microsecond) with open(filename, 'w') as crash_dump: crash_dump.write('Traceback (most recent call last):\n') print_tb(exc_info()[2], file=crash_dump) crash_dump.write('{}: {}\n'.format(exc_info()[0].__name__, exc_info()[1])) finally: exit()
def on_mouse_motion(self, x, y, dx, dy): if x in range(self.viewport.x1, self.viewport.x2) and y in range( self.viewport.y1, self.viewport.y2): if self.state != HOVER: self.state = HOVER WINDOW.set_mouse_cursor(HAND_CURSOR) elif self.state != NORMAL: self.state = NORMAL WINDOW.set_mouse_cursor(DEFAULT_CURSOR)
def on_accept_changes(self, windowed_resolution, display_fps, fade_animations_enabled, clock_24h_enabled, level_up_notification_enabled, feature_unlocked_notification_enabled, construction_completed_notification_enabled, enough_money_notification_enabled, bonus_expired_notification_enabled, shop_storage_notification_enabled, voice_not_found_notification_enabled, master_volume, announcements_enabled): self.settings.on_accept_changes( windowed_resolution, display_fps, fade_animations_enabled, clock_24h_enabled, level_up_notification_enabled, feature_unlocked_notification_enabled, construction_completed_notification_enabled, enough_money_notification_enabled, bonus_expired_notification_enabled, shop_storage_notification_enabled, voice_not_found_notification_enabled, master_volume, announcements_enabled) self.on_update_fade_animation_state(fade_animations_enabled) self.on_update_clock_state(clock_24h_enabled) self.on_change_level_up_notification_state( level_up_notification_enabled) self.on_change_feature_unlocked_notification_state( feature_unlocked_notification_enabled) self.on_change_construction_completed_notification_state( construction_completed_notification_enabled) self.on_change_enough_money_notification_state( enough_money_notification_enabled) self.on_change_bonus_expired_notification_state( bonus_expired_notification_enabled) self.on_change_shop_storage_notification_state( shop_storage_notification_enabled) self.on_change_voice_not_found_notification_state( voice_not_found_notification_enabled) self.on_master_volume_update(master_volume) self.on_update_announcements_state(announcements_enabled) if not WINDOW.fullscreen: WINDOW.set_size(*windowed_resolution) if display_fps: self.view.fps_display.on_activate() else: self.view.fps_display.on_deactivate()
def on_draw(): # clear surface WINDOW.clear() for batch in BATCHES: BATCHES[batch].invalidate() # draw main batch: environment, main map, signals, trains with MAP_CAMERA: BATCHES['main_batch'].draw() # draw mini map batch: mini map BATCHES['mini_map_batch'].draw() # draw all vertices with shaders self.app.on_apply_shaders_and_draw_vertices() # draw ui batch: text labels, buttons BATCHES['ui_batch'].draw() self.on_mouse_motion_event_counter = 0 self.on_mouse_drag_event_counter = 0 self.on_mouse_scroll_event_counter = 0
def on_fullscreen_button_click(self): WINDOW.set_size(*self.model.fullscreen_resolution) if self.model.fullscreen_mode_available: self.on_fullscreen_mode_turned_on()
def on_restore_button_click(self): self.on_fullscreen_mode_turned_off() WINDOW.set_size(*self.settings.model.windowed_resolution)
def on_iconify_game(button): WINDOW.minimize()
def on_close_game(button): WINDOW.dispatch_event('on_close')
def on_fullscreen_mode_turned_off(self): self.fullscreen_mode = FALSE WINDOW.set_fullscreen(fullscreen=self.fullscreen_mode)
def on_fullscreen_mode_turned_on(self): self.fullscreen_mode = TRUE WINDOW.set_fullscreen(fullscreen=self.fullscreen_mode)
def on_mouse_leave(self, x, y): self.state = NORMAL WINDOW.set_mouse_cursor(DEFAULT_CURSOR)
def on_mouse_release(self, x, y, button, modifiers): self.value_update_mode = False WINDOW.set_mouse_cursor(DEFAULT_CURSOR)