#include "tracker_frame.h" #include #include #include #include #include "achievements_pane.h" #include "ap_state.h" #include "connection_dialog.h" #include "settings_dialog.h" #include "tracker_config.h" #include "tracker_panel.h" #include "version.h" enum TrackerFrameIds { ID_CONNECT = 1, ID_CHECK_FOR_UPDATES = 2, ID_SETTINGS = 3 }; wxDEFINE_EVENT(STATE_CHANGED, wxCommandEvent); wxDEFINE_EVENT(STATUS_CHANGED, wxCommandEvent); TrackerFrame::TrackerFrame() : wxFrame(nullptr, wxID_ANY, "Lingo Archipelago Tracker", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE | wxFULL_REPAINT_ON_RESIZE) { ::wxInitAllImageHandlers(); AP_SetTrackerFrame(this); SetSize(1280, 728); wxMenu *menuFile = new wxMenu(); menuFile->Append(ID_CONNECT, "&Connect"); menuFile->Append(ID_SETTINGS, "&Settings"); menuFile->Append(wxID_EXIT); wxMenu *menuHelp = new wxMenu(); menuHelp->Append(wxID_ABOUT); menuHelp->Append(ID_CHECK_FOR_UPDATES, "Check for Updates"); 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(wxEVT_MENU, &TrackerFrame::OnSettings, this, ID_SETTINGS); Bind(wxEVT_MENU, &TrackerFrame::OnCheckForUpdates, this, ID_CHECK_FOR_UPDATES); Bind(STATE_CHANGED, &TrackerFrame::OnStateChanged, this); Bind(STATUS_CHANGED, &TrackerFrame::OnStatusChanged, this); wxChoicebook *choicebook = new wxChoicebook(this, wxID_ANY); achievements_pane_ = new AchievementsPane(this); choicebook->AddPage(achievements_pane_, "Achievements"); tracker_panel_ = new TrackerPanel(this); wxBoxSizer *top_sizer = new wxBoxSizer(wxHORIZONTAL); top_sizer->Add(choicebook, wxSizerFlags().Expand().Proportion(1)); top_sizer->Add(tracker_panel_, wxSizerFlags().Expand().Proportion(3)); SetSizerAndFit(top_sizer); if (!GetTrackerConfig().asked_to_check_for_updates) { GetTrackerConfig().asked_to_check_for_updates = true; if (wxMessageBox( "Check for updates automatically when the tracker is opened?", "Lingo AP Tracker", wxYES_NO) == wxYES) { GetTrackerConfig().should_check_for_updates = true; } else { GetTrackerConfig().should_check_for_updates = false; } GetTrackerConfig().Save(); } if (GetTrackerConfig().should_check_for_updates) { CheckForUpdates(/*manual=*/false); } } 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) { std::ostringstream message_text; message_text << "Lingo Archipelago Tracker " << kTrackerVersion << " by hatkirby"; wxMessageBox(message_text.str(), "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) { GetTrackerConfig().ap_server = dlg.GetServerValue(); GetTrackerConfig().ap_player = dlg.GetPlayerValue(); GetTrackerConfig().ap_password = dlg.GetPasswordValue(); GetTrackerConfig().Save(); AP_Connect(dlg.GetServerValue(), dlg.GetPlayerValue(), dlg.GetPasswordValue()); } } void TrackerFrame::OnSettings(wxCommandEvent &event) { SettingsDialog dlg; if (dlg.ShowModal() == wxID_OK) { GetTrackerConfig().should_check_for_updates = dlg.GetShouldCheckForUpdates(); GetTrackerConfig().hybrid_areas = dlg.GetHybridAreas(); GetTrackerConfig().show_hunt_panels = dlg.GetShowHuntPanels(); GetTrackerConfig().Save(); UpdateIndicators(); } } void TrackerFrame::OnCheckForUpdates(wxCommandEvent &event) { CheckForUpdates(/*manual=*/true); } void TrackerFrame::OnStateChanged(wxCommandEvent &event) { tracke
#ifndef CONNECTION_DIALOG_H_E526D0E7
#define CONNECTION_DIALOG_H_E526D0E7

#include <wx/wxprec.h>

#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif

#include <string>
#include <wx/listbox.h>

class ConnectionDialog : public wxDialog {
 public:
  ConnectionDialog();

  std::string GetServerValue() { return server_box_->GetValue().ToStdString(); }

  std::string GetPlayerValue() { return player_box_->GetValue().ToStdString(); }

  std::string GetPasswordValue() {
    return password_box_->GetValue().ToStdString();
  }

 private:
   void OnOldConnectionChosen(wxCommandEvent& e);

  wxTextCtrl* server_box_;
  wxTextCtrl* player_box_;
  wxTextCtrl* password_box_;
  wxListBox* history_list_;
};

#endif /* end of include guard: CONNECTION_DIALOG_H_E526D0E7 */