From f678c525a7af4d8cf5ff0c85f4f8172816dca54c Mon Sep 17 00:00:00 2001 From: Taylor Richards Date: Fri, 11 Mar 2016 16:24:41 -0500 Subject: [PATCH] support for mission goals in GUI --- include/stand_gui.h | 178 ++++++++++++++++++++++++++++++++++++++ src/network/stand_gui.cpp | 64 +++++++++++++- 2 files changed, 240 insertions(+), 2 deletions(-) diff --git a/include/stand_gui.h b/include/stand_gui.h index 7b1e996..1492e93 100644 --- a/include/stand_gui.h +++ b/include/stand_gui.h @@ -118,6 +118,7 @@ class Standalone : public wxDialog wxStaticText* m_M_ngSecurity; wxStaticText* m_M_ngRespawns; wxTreeCtrl* m_M_Goals; + wxTreeItemId m_M_GoalItems[3]; wxChoice* m_P_Players; wxStaticText* m_P_ShipType; @@ -204,4 +205,181 @@ class StandaloneApp: public wxApp } }; + +const char * goal_ord_xpm[] = { +"16 16 16 1", +" c #000000", +". c #800000", +"+ c #008000", +"@ c #808000", +"# c #000080", +"$ c #800080", +"% c #008080", +"& c #C0C0C0", +"* c #808080", +"= c #FF0000", +"- c #00FF00", +"; c #FFFF00", +"> c #0000FF", +", c #FF00FF", +"' c #00FFFF", +") c #FFFFFF", +",,,,,,,,,,,,,,,,", +",,,,*********,,,", +",,,,*)))))))&*,,", +",,,,*)))))))&)*,", +",,,,*)) )) ", +",,,,*)))))))))& ", +",,,,*)) ) ))& ", +",,,,*)))))))))& ", +",,,,*)) ) ))& ", +",,,,*)))))))))& ", +",,,,*)) ) ))& ", +",,,,*)))))))))& ", +",,,,*)))))))))& ", +",,,,*&&&&&&&&&& ", +",,,, ", +",,,,,,,,,,,,,,,,"}; + +const char * goal_none_xpm[] = { +"16 16 16 1", +" c #000000", +". c #800000", +"+ c #008000", +"@ c #808000", +"# c #000080", +"$ c #800080", +"% c #008080", +"& c #C0C0C0", +"* c #808080", +"= c #FF0000", +"- c #00FF00", +"; c #FFFF00", +"> c #0000FF", +", c #FF00FF", +"' c #00FFFF", +") c #FFFFFF", +"))))))****))))))", +")))**********)))", +"))************))", +")**************)", +")**************)", +")**************)", +"****************", +"****************", +"****************", +"****************", +")**************)", +")**************)", +")**************)", +"))************))", +")))**********)))", +"))))))****))))))"}; + +const char * goal_inc_xpm[] = { +"16 16 16 1", +" c #000000", +". c #800000", +"+ c #008000", +"@ c #808000", +"# c #000080", +"$ c #800080", +"% c #008080", +"& c #C0C0C0", +"* c #808080", +"= c #FF0000", +"- c #00FF00", +"; c #FFFF00", +"> c #0000FF", +", c #FF00FF", +"' c #00FFFF", +") c #FFFFFF", +"))))));;;;))))))", +")));;;;;;;;;;)))", +"));;;;;;;;;;;;))", +");;;;;;;;;;;;;;)", +");;;;;;;;;;;;;;)", +");;;;;;;;;;;;;;)", +";;;;;;;;;;;;;;;;", +";;;;;;;;;;;;;;;;", +";;;;;;;;;;;;;;;;", +";;;;;;;;;;;;;;;;", +");;;;;;;;;;;;;;)", +");;;;;;;;;;;;;;)", +");;;;;;;;;;;;;;)", +"));;;;;;;;;;;;))", +")));;;;;;;;;;)))", +"))))));;;;))))))"}; + +const char * goal_com_xpm[] = { +"16 16 16 1", +" c #000000", +". c #800000", +"+ c #008000", +"@ c #808000", +"# c #000080", +"$ c #800080", +"% c #008080", +"& c #C0C0C0", +"* c #808080", +"= c #FF0000", +"- c #00FF00", +"; c #FFFF00", +"> c #0000FF", +", c #FF00FF", +"' c #00FFFF", +") c #FFFFFF", +"))))))----))))))", +")))----------)))", +"))------------))", +")--------------)", +")--------------)", +")--------------)", +"----------------", +"----------------", +"----------------", +"----------------", +")--------------)", +")--------------)", +")--------------)", +"))------------))", +")))----------)))", +"))))))----))))))"}; + +const char * goal_fail_xpm[] = { +"16 16 16 1", +" c #000000", +". c #800000", +"+ c #008000", +"@ c #808000", +"# c #000080", +"$ c #800080", +"% c #008080", +"& c #C0C0C0", +"* c #808080", +"= c #FF0000", +"- c #00FF00", +"; c #FFFF00", +"> c #0000FF", +", c #FF00FF", +"' c #00FFFF", +") c #FFFFFF", +"))))))====))))))", +")))==========)))", +"))============))", +")==============)", +")==============)", +")==============)", +"================", +"================", +"================", +"================", +")==============)", +")==============)", +")==============)", +"))============))", +")))==========)))", +"))))))====))))))"}; + + #endif // STAND_GUI_H diff --git a/src/network/stand_gui.cpp b/src/network/stand_gui.cpp index 531620a..d4b24b7 100644 --- a/src/network/stand_gui.cpp +++ b/src/network/stand_gui.cpp @@ -474,7 +474,24 @@ void Standalone::createTab_Multi(wxNotebook* parent) m_staticText11->Wrap( -1 ); bSizer4->Add( m_staticText11, 0, wxALL, 5 ); - m_M_Goals = new wxTreeCtrl( panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTR_DEFAULT_STYLE|wxTR_HIDE_ROOT ); + m_M_Goals = new wxTreeCtrl( panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTR_HIDE_ROOT|wxTR_NO_BUTTONS ); + + wxImageList *goal_imgs = new wxImageList(16, 16); + + goal_imgs->Add( wxBitmap(goal_ord_xpm), wxColour(0xff, 0x0, 0xff) ); + goal_imgs->Add( wxBitmap(goal_none_xpm), wxColour(0xff, 0xff, 0xff) ); + goal_imgs->Add( wxBitmap(goal_inc_xpm), wxColour(0xff, 0xff, 0xff) ); + goal_imgs->Add( wxBitmap(goal_com_xpm), wxColour(0xff, 0xff, 0xff) ); + goal_imgs->Add( wxBitmap(goal_fail_xpm), wxColour(0xff, 0xff, 0xff) ); + + m_M_Goals->AssignImageList(goal_imgs); + + wxTreeItemId root = m_M_Goals->AddRoot( wxT("Goals") ); + + m_M_GoalItems[0] = m_M_Goals->AppendItem(root, wxT("Primary Objectives"), 0); + m_M_GoalItems[1] = m_M_Goals->AppendItem(root, wxT("Secondary Objectives"), 0); + m_M_GoalItems[2] = m_M_Goals->AppendItem(root, wxT("Bonus Objectives"), 0); + bSizer4->Add( m_M_Goals, 1, wxALL|wxEXPAND, 5 ); bSizer3->Add(bSizer4, 1, wxEXPAND); @@ -1108,7 +1125,10 @@ void Standalone::ResetAll() m_M_ngMaxObservers->SetLabel(""); m_M_ngSecurity->SetLabel(""); m_M_ngRespawns->SetLabel(""); - m_M_Goals->DeleteAllItems(); + + for (int idx = 0; idx < 3; idx++) { + m_M_Goals->DeleteChildren( m_M_GoalItems[idx] ); + } m_P_Players->Clear(); m_P_ShipType->SetLabel(""); @@ -1382,7 +1402,47 @@ void Standalone::wsMessage(const char *msg, size_t len) } else if (cmd == "fps ") { m_M_FPSRel->SetLabel(msg+6); } else if (cmd == "goal") { + wxArrayString objectives = wxSplit(msg+7, ';'); + + size_t n_objectives = objectives.size(); + wxASSERT(n_objectives == 3); + + for (size_t idx = 0; idx < n_objectives; idx++) { + wxArrayString goals = wxSplit( objectives.Item(idx), ',' ); + size_t n_goals = goals.size(); + + for (size_t j = 0; j < n_goals; j++) { + char status = goals.Item(j).GetChar(0); + wxString goal = goals.Item(j).substr(2); + int img = 1; + + switch (status) { + case 'i': { + if (goal == "none") { + img = 1; + } else { + img = 2; + } + + break; + } + + case 'c': + img = 3; + break; + + case 'f': + img = 4; + break; + + default: + break; + } + + m_M_Goals->AppendItem(m_M_GoalItems[idx], goal, img); + } + } } } // player tab -- 2.39.2