about summary refs log tree commit diff stats
path: root/series/trunk/includes/template.php
diff options
context:
space:
mode:
Diffstat (limited to 'series/trunk/includes/template.php')
0 files changed, 0 insertions, 0 deletions
180a4'>^
70f1c62 ^


d7eb71d

9798316 ^

116ba41 ^

22014b9 ^

d7eb71d
116ba41 ^
d7eb71d















116ba41 ^
70f1c62 ^

9798316 ^
09d67fb ^
d7eb71d

116ba41 ^
70f1c62 ^



116ba41 ^

09d67fb ^
70f1c62 ^
09d67fb ^

d7eb71d





116ba41 ^








70f1c62 ^








1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79

                          

                              

                          

                                        


                                               

                                                               

                             

                                     

                     
                                  
                                           















                                                             
                                                               

                                                             
 
                                          

 
                                                          



                                                             

 
                                       
                                                

 





                                                                    








                                                                    








                                                           
#include "tracker_frame.h"

#include "ap_state.h"
#include "connection_dialog.h"
#include "tracker_panel.h"

enum TrackerFrameIds { ID_CONNECT = 1 };

wxDEFINE_EVENT(STATE_CHANGED, wxCommandEvent);
wxDEFINE_EVENT(STATUS_CHANGED, wxCommandEvent);

TrackerFrame::TrackerFrame()
    : wxFrame(nullptr, wxID_ANY, "Lingo Archipelago Tracker") {
  ::wxInitAllImageHandlers();

  GetAPState().SetTrackerFrame(this);

  SetSize(1280, 728);

  wxMenu *menuFile = new wxMenu();
  menuFile->Append(ID_CONNECT, "&Connect");
  menuFile->Append(wxID_EXIT);

  wxMenu *menuHelp = new wxMenu();
  menuHelp->Append(wxID_ABOUT);

  wxMenuBar *menuBar = new wxMenuBar();
  menuBar->Append(menuFile, "&File");
  menuBar->Append(menuHelp, "&Help");

  SetMenuBar(menuBar);

  CreateStatusBar();
  SetStatusText("Not connected to Archipelago.");

  Bind(wxEVT_MENU, &TrackerFrame::OnAbout, this, wxID_ABOUT);
  Bind(wxEVT_MENU, &TrackerFrame::OnExit, this, wxID_EXIT);
  Bind(wxEVT_MENU, &TrackerFrame::OnConnect, this, ID_CONNECT);
  Bind(STATE_CHANGED, &TrackerFrame::OnStateChanged, this);
  Bind(STATUS_CHANGED, &TrackerFrame::OnStatusChanged, this);

  tracker_panel_ = new TrackerPanel(this);
}

void TrackerFrame::SetStatusMessage(std::string message) {
  wxCommandEvent *event = new wxCommandEvent(STATUS_CHANGED);
  event->SetString(message.c_str());

  QueueEvent(event);
}

void TrackerFrame::UpdateIndicators() {
  QueueEvent(new wxCommandEvent(STATE_CHANGED));
}

void TrackerFrame::OnAbout(wxCommandEvent &event) {
  wxMessageBox("Lingo Archipelago Tracker by hatkirby",
               "About lingo-ap-tracker", wxOK | wxICON_INFORMATION);
}

void TrackerFrame::OnExit(wxCommandEvent &event) { Close(true); }

void TrackerFrame::OnConnect(wxCommandEvent &event) {
  ConnectionDialog dlg;

  if (dlg.ShowModal() == wxID_OK) {
    GetAPState().Connect(dlg.GetServerValue(), dlg.GetPlayerValue(),
                         dlg.GetPasswordValue());
  }
}

void TrackerFrame::OnStateChanged(wxCommandEvent &event) {
  tracker_panel_->UpdateIndicators();
  Refresh();
}

void TrackerFrame::OnStatusChanged(wxCommandEvent &event) {
  SetStatusText(event.GetString());
}