00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "FSClient.h"
00027 #include <wx/sashwin.h>
00028
00029 #include "OrdersFleet.h"
00030
00031 #ifdef _DEBUG
00032 #define new DEBUG_NEW
00033 #endif
00034
00035 BEGIN_EVENT_TABLE(OrdersFleet, wxPanel)
00036 EVT_BUTTON(ID_Rename, OrdersFleet::Rename)
00037 EVT_BUTTON(ID_Goto, OrdersFleet::Goto)
00038 END_EVENT_TABLE()
00039
00040 OrdersFleet::OrdersFleet(MainWindow * parent, wxWindow * frame)
00041 : wxPanel(frame)
00042 {
00043 mMainWindow = parent;
00044 mFleet = NULL;
00045
00046 wxBoxSizer * top = new wxBoxSizer(wxVERTICAL);
00047 mFleetStaticBox = new wxStaticBoxSizer(wxVERTICAL, this, "");
00048
00049 mFleetStaticBox->Add(new wxButton(this, ID_Previous, "Previous"),
00050 0,
00051 wxALL,
00052 5);
00053
00054 mFleetStaticBox->Add(new wxButton(this, ID_Next, "Next"),
00055 0,
00056 wxALL,
00057 5);
00058
00059 mFleetStaticBox->Add(new wxButton(this, ID_Rename, "Rename"),
00060 0,
00061 wxALL,
00062 5);
00063
00064 top->Add(mFleetStaticBox, 0, wxALIGN_LEFT);
00065
00066 mLocationStaticBox = new wxStaticBoxSizer(wxHORIZONTAL, this, "");
00067
00068 mLocationStaticBox->Add(new wxButton(this, ID_Goto, "Goto"),
00069 0,
00070 wxALL,
00071 5);
00072
00073 mLocationStaticBox->Add(new wxButton(this, ID_Transfer, "Transfer"),
00074 0,
00075 wxALL,
00076 5);
00077
00078 top->Add(mLocationStaticBox, 0, wxALIGN_LEFT);
00079
00080
00081 SetSizer(top);
00082
00083 top->SetSizeHints(this);
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121 }
00122
00123 OrdersFleet::~OrdersFleet()
00124 {
00125 }
00126
00127 void OrdersFleet::SetLocation(Fleet * fleet)
00128 {
00129 mFleet = fleet;
00130 string t;
00131 t = fleet->GetName(TheGame->GetCurrentPlayer());
00132 mFleetStaticBox->GetStaticBox()->SetLabel(t.c_str());
00133
00134 Planet * p = dynamic_cast<Planet *>(fleet->GetAlsoHere()->at(0));
00135 if (p == NULL)
00136 mLocationStaticBox->GetStaticBox()->SetLabel("In Deep Space");
00137 else {
00138 t = "Orbiting ";
00139 t += p->GetName();
00140 mLocationStaticBox->GetStaticBox()->SetLabel(t.c_str());
00141 }
00142 }
00143
00144 void OrdersFleet::Rename(wxCommandEvent &)
00145 {
00146 if (mFleet != NULL) {
00147 wxDialog dialog;
00148 dialog.Create(this, -1, "Rename Fleet", wxDefaultPosition, wxSize(300, 100));
00149 wxBoxSizer * top = new wxBoxSizer(wxVERTICAL);
00150 wxBoxSizer * size1 = new wxBoxSizer(wxHORIZONTAL);
00151 size1->Add(new wxStaticText(&dialog, -1, "New name:"), 0, wxALL, 5);
00152 wxTextCtrl * tb = new wxTextCtrl(&dialog, -1, mFleet->GetName(TheGame->GetCurrentPlayer()).c_str(), wxDefaultPosition, wxSize(200, -1));
00153 size1->Add(tb, 1, wxALL, 5);
00154 top->Add(size1, 0, wxEXPAND | wxALIGN_LEFT);
00155 top->Add(dialog.CreateStdDialogButtonSizer(wxOK | wxCANCEL), 0, wxALIGN_CENTER);
00156 dialog.SetSizer(top);
00157
00158 if (dialog.ShowModal() == wxID_OK) {
00159 string s = tb->GetValue();
00160 if (s != mFleet->GetName(TheGame->GetCurrentPlayer())) {
00161 mFleet->SetName(s.c_str());
00162 mMainWindow->SetLocation(mFleet);
00163 }
00164 }
00165 }
00166 }
00167
00168 void OrdersFleet::Goto(wxCommandEvent &)
00169 {
00170 if (mFleet == NULL)
00171 return;
00172
00173 Planet * p = dynamic_cast<Planet *>(mFleet->GetAlsoHere()->at(0));
00174 if (p != NULL)
00175 mMainWindow->SetLocation(p);
00176 }