summaryrefslogtreecommitdiffhomepage
path: root/Stars45/NetUnitDlg.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Stars45/NetUnitDlg.cpp')
-rw-r--r--Stars45/NetUnitDlg.cpp818
1 files changed, 409 insertions, 409 deletions
diff --git a/Stars45/NetUnitDlg.cpp b/Stars45/NetUnitDlg.cpp
index 4d227e6..524f1be 100644
--- a/Stars45/NetUnitDlg.cpp
+++ b/Stars45/NetUnitDlg.cpp
@@ -1,15 +1,15 @@
/* Project Starshatter 5.0
- Destroyer Studios LLC
- Copyright © 1997-2007. All Rights Reserved.
+ Destroyer Studios LLC
+ Copyright © 1997-2007. All Rights Reserved.
- SUBSYSTEM: Stars.exe
- FILE: NetUnitDlg.cpp
- AUTHOR: John DiCamillo
+ SUBSYSTEM: Stars.exe
+ FILE: NetUnitDlg.cpp
+ AUTHOR: John DiCamillo
- OVERVIEW
- ========
- Main Menu Dialog Active Window class
+ OVERVIEW
+ ========
+ Main Menu Dialog Active Window class
*/
#include "MemDebug.h"
@@ -51,13 +51,13 @@ DEF_MAP_CLIENT(NetUnitDlg, OnCancel);
// +--------------------------------------------------------------------+
NetUnitDlg::NetUnitDlg(Screen* s, FormDef& def, MenuScreen* mgr)
- : FormWindow(s, 0, 0, s->Width(), s->Height()), manager(mgr),
- net_lobby(0), unit_index(-1)
+: FormWindow(s, 0, 0, s->Width(), s->Height()), manager(mgr),
+net_lobby(0), unit_index(-1)
{
- last_chat = 0;
- host_mode = false;
-
- Init(def);
+ last_chat = 0;
+ host_mode = false;
+
+ Init(def);
}
NetUnitDlg::~NetUnitDlg()
@@ -69,37 +69,37 @@ NetUnitDlg::~NetUnitDlg()
void
NetUnitDlg::RegisterControls()
{
- lst_players = (ListBox*) FindControl(201);
- lst_units = (ListBox*) FindControl(202);
- lst_chat = (ListBox*) FindControl(211);
- edt_chat = (EditBox*) FindControl(212);
+ lst_players = (ListBox*) FindControl(201);
+ lst_units = (ListBox*) FindControl(202);
+ lst_chat = (ListBox*) FindControl(211);
+ edt_chat = (EditBox*) FindControl(212);
- REGISTER_CLIENT(EID_SELECT, lst_units, NetUnitDlg, OnUnit);
+ REGISTER_CLIENT(EID_SELECT, lst_units, NetUnitDlg, OnUnit);
- if (edt_chat)
- edt_chat->SetText("");
+ if (edt_chat)
+ edt_chat->SetText("");
- btn_select = (Button*) FindControl(206);
- REGISTER_CLIENT(EID_CLICK, btn_select, NetUnitDlg, OnSelect);
+ btn_select = (Button*) FindControl(206);
+ REGISTER_CLIENT(EID_CLICK, btn_select, NetUnitDlg, OnSelect);
- btn_map = (Button*) FindControl(203);
- REGISTER_CLIENT(EID_CLICK, btn_map, NetUnitDlg, OnMap);
+ btn_map = (Button*) FindControl(203);
+ REGISTER_CLIENT(EID_CLICK, btn_map, NetUnitDlg, OnMap);
- btn_unmap = (Button*) FindControl(204);
- REGISTER_CLIENT(EID_CLICK, btn_unmap, NetUnitDlg, OnUnMap);
+ btn_unmap = (Button*) FindControl(204);
+ REGISTER_CLIENT(EID_CLICK, btn_unmap, NetUnitDlg, OnUnMap);
- btn_ban = (Button*) FindControl(205);
+ btn_ban = (Button*) FindControl(205);
- if (btn_ban) {
- REGISTER_CLIENT(EID_CLICK, btn_ban, NetUnitDlg, OnBan);
- REGISTER_CLIENT(EID_USER_1, btn_ban, NetUnitDlg, OnBanConfirm);
- }
+ if (btn_ban) {
+ REGISTER_CLIENT(EID_CLICK, btn_ban, NetUnitDlg, OnBan);
+ REGISTER_CLIENT(EID_USER_1, btn_ban, NetUnitDlg, OnBanConfirm);
+ }
- btn_apply = (Button*) FindControl(1);
- REGISTER_CLIENT(EID_CLICK, btn_apply, NetUnitDlg, OnApply);
+ btn_apply = (Button*) FindControl(1);
+ REGISTER_CLIENT(EID_CLICK, btn_apply, NetUnitDlg, OnApply);
- btn_cancel = (Button*) FindControl(2);
- REGISTER_CLIENT(EID_CLICK, btn_cancel, NetUnitDlg, OnCancel);
+ btn_cancel = (Button*) FindControl(2);
+ REGISTER_CLIENT(EID_CLICK, btn_cancel, NetUnitDlg, OnCancel);
}
// +--------------------------------------------------------------------+
@@ -107,48 +107,48 @@ NetUnitDlg::RegisterControls()
void
NetUnitDlg::Show()
{
- if (!IsShown()) {
- FormWindow::Show();
-
- // clear server data:
- if (lst_players) {
- lst_players->ClearItems();
- lst_players->SetSelectedStyle(ListBox::LIST_ITEM_STYLE_FILLED_BOX);
- lst_players->SetLeading(2);
- }
-
- if (lst_units) {
- lst_units->ClearItems();
- lst_units->SetSelectedStyle(ListBox::LIST_ITEM_STYLE_FILLED_BOX);
- lst_units->SetLeading(2);
- }
-
- if (lst_chat) lst_chat->ClearItems();
- last_chat = 0;
-
- if (btn_apply)
- btn_apply->SetEnabled(false);
-
- net_lobby = NetLobby::GetInstance();
- host_mode = false;
-
- if (net_lobby) {
- host_mode = net_lobby->IsHost();
- }
-
- if (host_mode) {
- btn_select->Hide();
- btn_map->Show();
- btn_unmap->Show();
- btn_ban->Show();
- }
- else {
- btn_select->Show();
- btn_map->Hide();
- btn_unmap->Hide();
- btn_ban->Hide();
- }
- }
+ if (!IsShown()) {
+ FormWindow::Show();
+
+ // clear server data:
+ if (lst_players) {
+ lst_players->ClearItems();
+ lst_players->SetSelectedStyle(ListBox::LIST_ITEM_STYLE_FILLED_BOX);
+ lst_players->SetLeading(2);
+ }
+
+ if (lst_units) {
+ lst_units->ClearItems();
+ lst_units->SetSelectedStyle(ListBox::LIST_ITEM_STYLE_FILLED_BOX);
+ lst_units->SetLeading(2);
+ }
+
+ if (lst_chat) lst_chat->ClearItems();
+ last_chat = 0;
+
+ if (btn_apply)
+ btn_apply->SetEnabled(false);
+
+ net_lobby = NetLobby::GetInstance();
+ host_mode = false;
+
+ if (net_lobby) {
+ host_mode = net_lobby->IsHost();
+ }
+
+ if (host_mode) {
+ btn_select->Hide();
+ btn_map->Show();
+ btn_unmap->Show();
+ btn_ban->Show();
+ }
+ else {
+ btn_select->Show();
+ btn_map->Hide();
+ btn_unmap->Hide();
+ btn_ban->Hide();
+ }
+ }
}
// +--------------------------------------------------------------------+
@@ -156,108 +156,108 @@ NetUnitDlg::Show()
void
NetUnitDlg::ExecFrame()
{
- ExecLobbyFrame();
+ ExecLobbyFrame();
- if (!net_lobby)
- return;
+ if (!net_lobby)
+ return;
- Text player_name;
+ Text player_name;
- if (Player::GetCurrentPlayer())
- player_name = Player::GetCurrentPlayer()->Name();
+ if (Player::GetCurrentPlayer())
+ player_name = Player::GetCurrentPlayer()->Name();
- if (btn_select) {
- bool enable = false;
+ if (btn_select) {
+ bool enable = false;
- if (lst_players && lst_units && btn_select->IsVisible()) {
- int sel_unit = lst_units->GetSelection();
+ if (lst_players && lst_units && btn_select->IsVisible()) {
+ int sel_unit = lst_units->GetSelection();
- enable = sel_unit >= 0 &&
- lst_units->GetItemText(sel_unit).length() == 0;
- }
+ enable = sel_unit >= 0 &&
+ lst_units->GetItemText(sel_unit).length() == 0;
+ }
- btn_select->SetEnabled(enable);
- }
+ btn_select->SetEnabled(enable);
+ }
- if (btn_map) {
- bool enable = false;
+ if (btn_map) {
+ bool enable = false;
- if (lst_players && lst_units && btn_map->IsVisible()) {
- int sel_play = lst_players->GetSelection();
- int sel_unit = lst_units->GetSelection();
+ if (lst_players && lst_units && btn_map->IsVisible()) {
+ int sel_play = lst_players->GetSelection();
+ int sel_unit = lst_units->GetSelection();
- enable = sel_unit >= 0 && sel_play >= 0 &&
- lst_units->GetItemText(sel_unit).length() == 0;
+ enable = sel_unit >= 0 && sel_play >= 0 &&
+ lst_units->GetItemText(sel_unit).length() == 0;
- if (enable && !host_mode) {
- NetUser* u = (NetUser*) lst_players->GetItemData(sel_play);
- if (!u || u->Name() != player_name)
- enable = false;
- }
- }
+ if (enable && !host_mode) {
+ NetUser* u = (NetUser*) lst_players->GetItemData(sel_play);
+ if (!u || u->Name() != player_name)
+ enable = false;
+ }
+ }
- btn_map->SetEnabled(enable);
- }
+ btn_map->SetEnabled(enable);
+ }
- if (btn_unmap) {
- bool enable = false;
+ if (btn_unmap) {
+ bool enable = false;
- if (lst_players && lst_units && btn_unmap->IsVisible()) {
- int sel_play = lst_players->GetSelection();
- int sel_unit = lst_units->GetSelection();
+ if (lst_players && lst_units && btn_unmap->IsVisible()) {
+ int sel_play = lst_players->GetSelection();
+ int sel_unit = lst_units->GetSelection();
- enable = sel_unit >= 0 && lst_units->GetItemText(sel_unit).length() > 0;
+ enable = sel_unit >= 0 && lst_units->GetItemText(sel_unit).length() > 0;
- if (enable && !host_mode) {
- NetUser* u = (NetUser*) lst_units->GetItemData(sel_unit);
- if (!u || u->Name() != Player::GetCurrentPlayer()->Name())
- enable = false;
- }
- }
+ if (enable && !host_mode) {
+ NetUser* u = (NetUser*) lst_units->GetItemData(sel_unit);
+ if (!u || u->Name() != Player::GetCurrentPlayer()->Name())
+ enable = false;
+ }
+ }
- btn_unmap->SetEnabled(enable);
- }
+ btn_unmap->SetEnabled(enable);
+ }
- if (btn_ban) {
- bool enable = false;
+ if (btn_ban) {
+ bool enable = false;
- if (lst_players && lst_units && host_mode && btn_ban->IsVisible()) {
- int sel_play = lst_players->GetSelection();
- int sel_unit = lst_units->GetSelection();
+ if (lst_players && lst_units && host_mode && btn_ban->IsVisible()) {
+ int sel_play = lst_players->GetSelection();
+ int sel_unit = lst_units->GetSelection();
- enable = sel_play >= 0 && sel_unit < 0;
+ enable = sel_play >= 0 && sel_unit < 0;
- if (enable) {
- NetUser* u = (NetUser*) lst_players->GetItemData(sel_play);
- if (u && u->Name() == player_name)
- enable = false;
- }
- }
+ if (enable) {
+ NetUser* u = (NetUser*) lst_players->GetItemData(sel_play);
+ if (u && u->Name() == player_name)
+ enable = false;
+ }
+ }
- btn_ban->SetEnabled(enable);
- }
+ btn_ban->SetEnabled(enable);
+ }
- if (btn_apply) {
- bool ok_to_start = net_lobby->IsMapped(player_name);
+ if (btn_apply) {
+ bool ok_to_start = net_lobby->IsMapped(player_name);
- NetUser* host = net_lobby->GetHost();
- if (host && !net_lobby->IsMapped(host->Name()))
- ok_to_start = false;
+ NetUser* host = net_lobby->GetHost();
+ if (host && !net_lobby->IsMapped(host->Name()))
+ ok_to_start = false;
- btn_apply->SetEnabled(ok_to_start);
- }
+ btn_apply->SetEnabled(ok_to_start);
+ }
- if (Keyboard::KeyDown(VK_RETURN)) {
- if (edt_chat && edt_chat->GetText().length() > 0) {
- SendChat(edt_chat->GetText());
- edt_chat->SetText("");
- }
- }
+ if (Keyboard::KeyDown(VK_RETURN)) {
+ if (edt_chat && edt_chat->GetText().length() > 0) {
+ SendChat(edt_chat->GetText());
+ edt_chat->SetText("");
+ }
+ }
- CheckUnitMapping();
- GetChat();
- GetUnits();
- GetAvailable();
+ CheckUnitMapping();
+ GetChat();
+ GetUnits();
+ GetAvailable();
}
// +--------------------------------------------------------------------+
@@ -265,21 +265,21 @@ NetUnitDlg::ExecFrame()
void
NetUnitDlg::ExecLobbyFrame()
{
- Starshatter* stars = Starshatter::GetInstance();
+ Starshatter* stars = Starshatter::GetInstance();
- if (!net_lobby) {
- manager->ShowNetClientDlg();
- }
+ if (!net_lobby) {
+ manager->ShowNetClientDlg();
+ }
- else if (net_lobby->GetLastError() != 0) {
- if (net_lobby->IsClient()) {
- if (stars)
- stars->StopLobby();
+ else if (net_lobby->GetLastError() != 0) {
+ if (net_lobby->IsClient()) {
+ if (stars)
+ stars->StopLobby();
- net_lobby = 0;
- manager->ShowNetClientDlg();
- }
- }
+ net_lobby = 0;
+ manager->ShowNetClientDlg();
+ }
+ }
}
// +--------------------------------------------------------------------+
@@ -290,95 +290,95 @@ static int num_users = 0;
void
NetUnitDlg::CheckUnitMapping()
{
- if (net_lobby && lst_units) {
- ListIter<NetUnitEntry> iter = net_lobby->GetUnitMap();
- List<NetUnitEntry>& units = iter.container();
- List<NetUser>& users = net_lobby->GetUsers();
-
- if (users.size() != num_users) {
- assignment_change = true;
- num_users = users.size();
- }
-
- if (units.size() != lst_units->NumItems()) {
- assignment_change = true;
- }
-
- else if (lst_units->NumItems()) {
- for (int i = 0; i < units.size(); i++) {
- NetUnitEntry* e = units.at(i);
- Text user_name = e->GetUserName();
- NetUser* u = net_lobby->FindUserByName(user_name);
-
- if (lst_units->GetItemData(i) != (DWORD) u)
- assignment_change = true;
- }
- }
- }
+ if (net_lobby && lst_units) {
+ ListIter<NetUnitEntry> iter = net_lobby->GetUnitMap();
+ List<NetUnitEntry>& units = iter.container();
+ List<NetUser>& users = net_lobby->GetUsers();
+
+ if (users.size() != num_users) {
+ assignment_change = true;
+ num_users = users.size();
+ }
+
+ if (units.size() != lst_units->NumItems()) {
+ assignment_change = true;
+ }
+
+ else if (lst_units->NumItems()) {
+ for (int i = 0; i < units.size(); i++) {
+ NetUnitEntry* e = units.at(i);
+ Text user_name = e->GetUserName();
+ NetUser* u = net_lobby->FindUserByName(user_name);
+
+ if (lst_units->GetItemData(i) != (DWORD) u)
+ assignment_change = true;
+ }
+ }
+ }
}
void
NetUnitDlg::GetAvailable()
{
- if (!lst_players) return;
-
- Text player_name;
-
- if (Player::GetCurrentPlayer())
- player_name = Player::GetCurrentPlayer()->Name();
-
- if (net_lobby) {
- List<NetUser> available_users;
-
- NetUser* u = net_lobby->GetLocalUser();
- if (u) {
- bool assigned = false;
- ListIter<NetUnitEntry> iter = net_lobby->GetUnitMap();
- while (++iter) {
- NetUnitEntry* unit = iter.value();
- if (unit->GetUserName() == u->Name())
- assigned = true;
- }
-
- if (!assigned)
- available_users.append(u);
- }
-
- ListIter<NetUser> iter = net_lobby->GetUsers();
- while (++iter) {
- NetUser* u = iter.value();
- bool assigned = false;
- ListIter<NetUnitEntry> iter = net_lobby->GetUnitMap();
- while (++iter) {
- NetUnitEntry* unit = iter.value();
- if (unit->GetUserName() == u->Name())
- assigned = true;
- }
-
- if (!assigned) {
- available_users.append(u);
- }
- }
-
- if (available_users.size() != lst_players->NumItems()) {
- assignment_change = true;
- lst_players->ClearItems();
-
- for (int i = 0; i < available_users.size(); i++) {
- NetUser* u = available_users[i];
-
- Text name = Player::RankAbrv(u->Rank());
- name += " ";
- name += u->Name();
-
- lst_players->AddItemWithData(name.data(), (DWORD) u);
-
- if (!host_mode && u->Name() == player_name) {
- lst_players->SetSelected(lst_players->NumItems()-1);
- }
- }
- }
- }
+ if (!lst_players) return;
+
+ Text player_name;
+
+ if (Player::GetCurrentPlayer())
+ player_name = Player::GetCurrentPlayer()->Name();
+
+ if (net_lobby) {
+ List<NetUser> available_users;
+
+ NetUser* u = net_lobby->GetLocalUser();
+ if (u) {
+ bool assigned = false;
+ ListIter<NetUnitEntry> iter = net_lobby->GetUnitMap();
+ while (++iter) {
+ NetUnitEntry* unit = iter.value();
+ if (unit->GetUserName() == u->Name())
+ assigned = true;
+ }
+
+ if (!assigned)
+ available_users.append(u);
+ }
+
+ ListIter<NetUser> iter = net_lobby->GetUsers();
+ while (++iter) {
+ NetUser* u = iter.value();
+ bool assigned = false;
+ ListIter<NetUnitEntry> iter = net_lobby->GetUnitMap();
+ while (++iter) {
+ NetUnitEntry* unit = iter.value();
+ if (unit->GetUserName() == u->Name())
+ assigned = true;
+ }
+
+ if (!assigned) {
+ available_users.append(u);
+ }
+ }
+
+ if (available_users.size() != lst_players->NumItems()) {
+ assignment_change = true;
+ lst_players->ClearItems();
+
+ for (int i = 0; i < available_users.size(); i++) {
+ NetUser* u = available_users[i];
+
+ Text name = Player::RankAbrv(u->Rank());
+ name += " ";
+ name += u->Name();
+
+ lst_players->AddItemWithData(name.data(), (DWORD) u);
+
+ if (!host_mode && u->Name() == player_name) {
+ lst_players->SetSelected(lst_players->NumItems()-1);
+ }
+ }
+ }
+ }
}
// +--------------------------------------------------------------------+
@@ -386,54 +386,54 @@ NetUnitDlg::GetAvailable()
void
NetUnitDlg::GetUnits()
{
- if (!lst_units) return;
-
- if (net_lobby) {
- ListIter<NetUnitEntry> iter = net_lobby->GetUnitMap();
- List<NetUnitEntry>& units = iter.container();
- List<NetUser>& users = net_lobby->GetUsers();
-
- if (assignment_change) {
- lst_units->ClearItems();
-
- for (int i = 0; i < units.size(); i++) {
- NetUnitEntry* e = units.at(i);
-
- char name[64];
- char team[16];
-
- if (e->GetIndex())
- sprintf(name, "%s %d", e->GetElemName().data(), e->GetIndex());
- else
- strcpy(name, e->GetElemName().data());
-
- sprintf(team, "%d", e->GetIFF());
-
- Text user_name = e->GetUserName();
-
- NetUser* u = net_lobby->FindUserByName(user_name);
- if (u) {
- user_name = Player::RankAbrv(u->Rank());
- user_name += " ";
- user_name += u->Name();
- }
-
- int count = lst_units->AddItemWithData(user_name, (DWORD) u);
- lst_units->SetItemText(count-1, 1, name);
- lst_units->SetItemText(count-1, 2, e->GetDesign());
-
- if (lst_units->NumColumns() > 4) {
- lst_units->SetItemText(count-1, 3, Mission::RoleName(e->GetMissionRole()));
- lst_units->SetItemText(count-1, 4, team);
- }
- else if (lst_units->NumColumns() > 3) {
- lst_units->SetItemText(count-1, 3, team);
- }
- }
- }
- }
-
- assignment_change = false;
+ if (!lst_units) return;
+
+ if (net_lobby) {
+ ListIter<NetUnitEntry> iter = net_lobby->GetUnitMap();
+ List<NetUnitEntry>& units = iter.container();
+ List<NetUser>& users = net_lobby->GetUsers();
+
+ if (assignment_change) {
+ lst_units->ClearItems();
+
+ for (int i = 0; i < units.size(); i++) {
+ NetUnitEntry* e = units.at(i);
+
+ char name[64];
+ char team[16];
+
+ if (e->GetIndex())
+ sprintf(name, "%s %d", e->GetElemName().data(), e->GetIndex());
+ else
+ strcpy(name, e->GetElemName().data());
+
+ sprintf(team, "%d", e->GetIFF());
+
+ Text user_name = e->GetUserName();
+
+ NetUser* u = net_lobby->FindUserByName(user_name);
+ if (u) {
+ user_name = Player::RankAbrv(u->Rank());
+ user_name += " ";
+ user_name += u->Name();
+ }
+
+ int count = lst_units->AddItemWithData(user_name, (DWORD) u);
+ lst_units->SetItemText(count-1, 1, name);
+ lst_units->SetItemText(count-1, 2, e->GetDesign());
+
+ if (lst_units->NumColumns() > 4) {
+ lst_units->SetItemText(count-1, 3, Mission::RoleName(e->GetMissionRole()));
+ lst_units->SetItemText(count-1, 4, team);
+ }
+ else if (lst_units->NumColumns() > 3) {
+ lst_units->SetItemText(count-1, 3, team);
+ }
+ }
+ }
+ }
+
+ assignment_change = false;
}
// +--------------------------------------------------------------------+
@@ -441,48 +441,48 @@ NetUnitDlg::GetUnits()
void
NetUnitDlg::GetChat()
{
- if (!lst_chat) return;
-
- if (net_lobby) {
- int last_item = lst_chat->NumItems() - 1;
- int count = 0;
- bool added = false;
-
- ListIter<NetChatEntry> iter = net_lobby->GetChat();
- while (++iter) {
- NetChatEntry* c = iter.value();
-
- if (count++ > last_item) {
- int n = lst_chat->AddItem(c->GetUser());
- lst_chat->SetItemText(n-1, 1, c->GetMessage());
- added = true;
- }
- }
-
- if (added)
- lst_chat->EnsureVisible(lst_chat->NumItems()+1);
- }
+ if (!lst_chat) return;
+
+ if (net_lobby) {
+ int last_item = lst_chat->NumItems() - 1;
+ int count = 0;
+ bool added = false;
+
+ ListIter<NetChatEntry> iter = net_lobby->GetChat();
+ while (++iter) {
+ NetChatEntry* c = iter.value();
+
+ if (count++ > last_item) {
+ int n = lst_chat->AddItem(c->GetUser());
+ lst_chat->SetItemText(n-1, 1, c->GetMessage());
+ added = true;
+ }
+ }
+
+ if (added)
+ lst_chat->EnsureVisible(lst_chat->NumItems()+1);
+ }
}
void
NetUnitDlg::SendChat(Text msg)
{
- if (msg.length() < 1) return;
+ if (msg.length() < 1) return;
- Player* player = Player::GetCurrentPlayer();
+ Player* player = Player::GetCurrentPlayer();
- if (msg[0] >= '0' && msg[0] <= '9') {
- if (player) {
- Text macro = player->ChatMacro(msg[0] - '0');
+ if (msg[0] >= '0' && msg[0] <= '9') {
+ if (player) {
+ Text macro = player->ChatMacro(msg[0] - '0');
- if (macro.length())
- msg = macro;
- }
- }
+ if (macro.length())
+ msg = macro;
+ }
+ }
- if (net_lobby)
- net_lobby->AddChat(0, msg);
+ if (net_lobby)
+ net_lobby->AddChat(0, msg);
}
// +--------------------------------------------------------------------+
@@ -490,19 +490,19 @@ NetUnitDlg::SendChat(Text msg)
void
NetUnitDlg::OnUnit(AWEvent* event)
{
- if (!lst_units || host_mode) return;
+ if (!lst_units || host_mode) return;
- static DWORD unit_click_time = 0;
+ static DWORD unit_click_time = 0;
- int list_index = lst_units->GetListIndex();
+ int list_index = lst_units->GetListIndex();
- // double-click:
- if (list_index == unit_index && Game::RealTime() - unit_click_time < 350) {
- OnSelect(0);
- }
+ // double-click:
+ if (list_index == unit_index && Game::RealTime() - unit_click_time < 350) {
+ OnSelect(0);
+ }
- unit_click_time = Game::RealTime();
- unit_index = list_index;
+ unit_click_time = Game::RealTime();
+ unit_index = list_index;
}
// +--------------------------------------------------------------------+
@@ -510,24 +510,24 @@ NetUnitDlg::OnUnit(AWEvent* event)
void
NetUnitDlg::OnSelect(AWEvent* event)
{
- if (!lst_players || !lst_units) return;
+ if (!lst_players || !lst_units) return;
- Text player_name;
+ Text player_name;
- if (Player::GetCurrentPlayer())
- player_name = Player::GetCurrentPlayer()->Name();
+ if (Player::GetCurrentPlayer())
+ player_name = Player::GetCurrentPlayer()->Name();
- int sel_unit = lst_units->GetSelection();
+ int sel_unit = lst_units->GetSelection();
- if (net_lobby) {
- net_lobby->MapUnit(sel_unit, player_name, host_mode);
- lst_units->ClearItems();
- }
+ if (net_lobby) {
+ net_lobby->MapUnit(sel_unit, player_name, host_mode);
+ lst_units->ClearItems();
+ }
- assignment_change = true;
+ assignment_change = true;
- GetUnits();
- GetAvailable();
+ GetUnits();
+ GetAvailable();
}
// +--------------------------------------------------------------------+
@@ -535,107 +535,107 @@ NetUnitDlg::OnSelect(AWEvent* event)
void
NetUnitDlg::OnMap(AWEvent* event)
{
- if (!lst_players || !lst_units) return;
+ if (!lst_players || !lst_units) return;
- int sel_player = lst_players->GetSelection();
- int sel_unit = lst_units->GetSelection();
+ int sel_player = lst_players->GetSelection();
+ int sel_unit = lst_units->GetSelection();
- if (net_lobby) {
- NetUser* u = (NetUser*) lst_players->GetItemData(sel_player);
- net_lobby->MapUnit(sel_unit, u->Name(), host_mode);
- lst_units->ClearItems();
- }
+ if (net_lobby) {
+ NetUser* u = (NetUser*) lst_players->GetItemData(sel_player);
+ net_lobby->MapUnit(sel_unit, u->Name(), host_mode);
+ lst_units->ClearItems();
+ }
- assignment_change = true;
+ assignment_change = true;
- GetUnits();
- GetAvailable();
+ GetUnits();
+ GetAvailable();
}
void
NetUnitDlg::OnUnMap(AWEvent* event)
{
- if (!lst_players || !lst_units) return;
+ if (!lst_players || !lst_units) return;
- if (net_lobby) {
- net_lobby->MapUnit(lst_units->GetSelection(), 0, host_mode);
- lst_units->ClearItems();
- }
+ if (net_lobby) {
+ net_lobby->MapUnit(lst_units->GetSelection(), 0, host_mode);
+ lst_units->ClearItems();
+ }
- assignment_change = true;
+ assignment_change = true;
- GetUnits();
- GetAvailable();
+ GetUnits();
+ GetAvailable();
}
void
NetUnitDlg::OnBan(AWEvent* event)
{
- if (!lst_players) return;
+ if (!lst_players) return;
- int sel_player = lst_players->GetSelection();
+ int sel_player = lst_players->GetSelection();
- if (net_lobby) {
- NetUser* u = (NetUser*) lst_players->GetItemData(sel_player);
+ if (net_lobby) {
+ NetUser* u = (NetUser*) lst_players->GetItemData(sel_player);
- ConfirmDlg* confirm = manager->GetConfirmDlg();
- if (confirm) {
- char msg[512];
- sprintf(msg, Game::GetText("NetUnitDlg.are-you-sure").data(), u->Name());
- confirm->SetMessage(msg);
- confirm->SetTitle(Game::GetText("NetUnitDlg.confirm-ban"));
- confirm->SetParentControl(btn_ban);
+ ConfirmDlg* confirm = manager->GetConfirmDlg();
+ if (confirm) {
+ char msg[512];
+ sprintf(msg, Game::GetText("NetUnitDlg.are-you-sure").data(), u->Name());
+ confirm->SetMessage(msg);
+ confirm->SetTitle(Game::GetText("NetUnitDlg.confirm-ban"));
+ confirm->SetParentControl(btn_ban);
- manager->ShowConfirmDlg();
- }
+ manager->ShowConfirmDlg();
+ }
- else {
- OnBanConfirm(event);
- }
- }
+ else {
+ OnBanConfirm(event);
+ }
+ }
}
void
NetUnitDlg::OnBanConfirm(AWEvent* event)
{
- if (!lst_players) return;
+ if (!lst_players) return;
- int sel_player = lst_players->GetSelection();
+ int sel_player = lst_players->GetSelection();
- if (net_lobby) {
- NetUser* u = (NetUser*) lst_players->GetItemData(sel_player);
- net_lobby->BanUser(u);
- lst_units->ClearItems();
- }
+ if (net_lobby) {
+ NetUser* u = (NetUser*) lst_players->GetItemData(sel_player);
+ net_lobby->BanUser(u);
+ lst_units->ClearItems();
+ }
- GetUnits();
- GetAvailable();
+ GetUnits();
+ GetAvailable();
}
void
NetUnitDlg::OnApply(AWEvent* event)
{
- bool ok = false;
+ bool ok = false;
- if (net_lobby) {
- Mission* mission = net_lobby->GetSelectedMission();
+ if (net_lobby) {
+ Mission* mission = net_lobby->GetSelectedMission();
- if (mission) {
- net_lobby->GameStart();
- ok = true;
- }
- }
+ if (mission) {
+ net_lobby->GameStart();
+ ok = true;
+ }
+ }
- if (!ok) OnCancel(0);
+ if (!ok) OnCancel(0);
}
void
NetUnitDlg::OnCancel(AWEvent* event)
{
- if (net_lobby) {
- net_lobby->SelectMission(0);
- net_lobby = 0;
- }
+ if (net_lobby) {
+ net_lobby->SelectMission(0);
+ net_lobby = 0;
+ }
- manager->ShowNetLobbyDlg();
+ manager->ShowNetLobbyDlg();
}