def __image_button(self, img_normal, img_hover, img_active, action):
     ss = pf.get_simstate()
     with btc.ButtonStyle(normal=img_normal, hover=img_hover, active=img_active):
         if ss == pf.G_RUNNING:
             self.button_label("", action)
         else:
             self.button_label("", lambda: None)
Exemplo n.º 2
0
def toggle_pause(user, event):

    if event[0] == pf.SDL_SCANCODE_P and not pf.ui_text_edit_has_focus():
        ss = pf.get_simstate()
        if ss == pf.G_RUNNING:
            pf.set_simstate(pf.G_PAUSED_UI_RUNNING)
        else:
            pf.set_simstate(pf.G_RUNNING)
Exemplo n.º 3
0
def toggle_pause(user, event):

    if event[0] == pf.SDL_SCANCODE_P:
        ss = pf.get_simstate()
        if ss == pf.G_RUNNING:
            pf.set_simstate(pf.G_PAUSED_UI_RUNNING)
        else:
            pf.set_simstate(pf.G_RUNNING)
Exemplo n.º 4
0
    def __init__(self):
        super(DemoWindow, self).__init__("Permafrost Engine Demo", (25, 25, DemoWindow.WIDTH, DemoWindow.HEIGHT), 
            pf.NK_WINDOW_BORDER | pf.NK_WINDOW_MOVABLE | pf.NK_WINDOW_MINIMIZABLE | pf.NK_WINDOW_TITLE |  pf.NK_WINDOW_NO_SCROLLBAR, (1920, 1080))
        self.fac_names = []
        self.active_fac_idx = 0

        ss = pf.get_simstate()
        self.paused = (ss != pf.G_RUNNING)
Exemplo n.º 5
0
    def update(self):
        def factions_group():
            self.layout_row_dynamic(25, 1)
            for i in range(0, len(self.fac_names)):
                old = self.active_fac_idx
                on = self.selectable_label(self.fac_names[i],
                                           pf.NK_TEXT_ALIGN_LEFT,
                                           i == self.active_fac_idx)
                if on:
                    self.active_fac_idx = i
                if self.active_fac_idx != old:
                    pf.global_event(EVENT_CONTROLLED_FACTION_CHANGED, i)

        self.layout_row_dynamic(20, 1)
        self.label_colored_wrap("Controlled Faction:", (255, 255, 255))

        self.layout_row_dynamic(140, 1)
        self.group("Controlled Faction", pf.NK_WINDOW_BORDER, factions_group)

        self.layout_row_dynamic(5, 1)

        def on_exit():
            pf.global_event(pf.SDL_QUIT, None)

        def on_settings():
            pf.global_event(EVENT_SETTINGS_SHOW, None)

        def on_performance():
            pf.global_event(EVENT_PERF_SHOW, None)

        def on_pause_resume():
            if pf.get_simstate() != pf.G_RUNNING:
                pf.global_event(EVENT_SIMSTATE_CHANGE, pf.G_RUNNING)
            else:
                pf.global_event(EVENT_SIMSTATE_CHANGE, pf.G_PAUSED_UI_RUNNING)

        def on_session():
            pf.global_event(EVENT_SESSION_SHOW, None)

        self.layout_row_dynamic(30, 1)
        self.button_label("Settings", on_settings)

        self.layout_row_dynamic(30, 1)
        self.button_label("Performance", on_performance)

        text = lambda p: "Resume " if p else "Pause"
        self.layout_row_dynamic(30, 1)
        self.button_label(text(pf.get_simstate() != pf.G_RUNNING),
                          on_pause_resume)

        self.layout_row_dynamic(30, 1)
        self.button_label("Session", on_session)

        self.layout_row_dynamic(30, 1)
        self.button_label("Exit Demo", on_exit)
Exemplo n.º 6
0
    def __image_button(self, img_normal, img_hover, img_active, action):
        old = pf.button_style.normal, pf.button_style.hover, pf.button_style.active
        ss = pf.get_simstate()

        if ss == pf.G_RUNNING:
            pf.button_style.normal = img_normal
            pf.button_style.hover = img_hover
            pf.button_style.active = img_active
            self.button_label("", action)
        else:
            pf.button_style.normal = img_normal
            pf.button_style.hover = img_normal
            pf.button_style.active = img_normal
            self.button_label("", lambda: None)

        pf.button_style.normal, pf.button_style.hover, pf.button_style.active = old
Exemplo n.º 7
0
 def __on_session_save(self, event):
     self.__session_view.hide()
     ss = pf.get_simstate()
     pf.set_simstate(pf.G_PAUSED_UI_RUNNING)
     pf.save_session(event)
     pf.set_simstate(ss)
Exemplo n.º 8
0
 def on_pause_resume():
     if pf.get_simstate() != pf.G_RUNNING:
         pf.global_event(EVENT_SIMSTATE_CHANGE, pf.G_RUNNING)
     else:
         pf.global_event(EVENT_SIMSTATE_CHANGE, pf.G_PAUSED_UI_RUNNING)