summaryrefslogtreecommitdiffhomepage
path: root/Stars45/TacRefDlg.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Stars45/TacRefDlg.cpp')
-rw-r--r--Stars45/TacRefDlg.cpp974
1 files changed, 487 insertions, 487 deletions
diff --git a/Stars45/TacRefDlg.cpp b/Stars45/TacRefDlg.cpp
index a492bc2..1219612 100644
--- a/Stars45/TacRefDlg.cpp
+++ b/Stars45/TacRefDlg.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: TacRefDlg.cpp
- AUTHOR: John DiCamillo
+ SUBSYSTEM: Stars.exe
+ FILE: TacRefDlg.cpp
+ AUTHOR: John DiCamillo
- OVERVIEW
- ========
- Tactical Reference Dialog Active Window class
+ OVERVIEW
+ ========
+ Tactical Reference Dialog Active Window class
*/
#include "MemDebug.h"
@@ -46,26 +46,26 @@ DEF_MAP_CLIENT(TacRefDlg, OnCamZoom);
// +--------------------------------------------------------------------+
TacRefDlg::TacRefDlg(Screen* s, FormDef& def, MenuScreen* mgr)
- : FormWindow(s, 0, 0, s->Width(), s->Height()), manager(mgr),
- beauty(0), camview(0), imgview(0),
- txt_caption(0), txt_stats(0), txt_description(0),
- lst_designs(0), btn_close(0), btn_ships(0), btn_weaps(0),
- mode(MODE_NONE), radius(100), mouse_x(0), mouse_y(0),
- cam_zoom(2.5), cam_az(-PI/6), cam_el(PI/7), captured(false),
- ship_index(0), weap_index(0)
+: FormWindow(s, 0, 0, s->Width(), s->Height()), manager(mgr),
+beauty(0), camview(0), imgview(0),
+txt_caption(0), txt_stats(0), txt_description(0),
+lst_designs(0), btn_close(0), btn_ships(0), btn_weaps(0),
+mode(MODE_NONE), radius(100), mouse_x(0), mouse_y(0),
+cam_zoom(2.5), cam_az(-PI/6), cam_el(PI/7), captured(false),
+ship_index(0), weap_index(0)
{
- Init(def);
+ Init(def);
}
TacRefDlg::~TacRefDlg()
{
- if (beauty) {
- beauty->DelView(camview);
- beauty->DelView(imgview);
- }
+ if (beauty) {
+ beauty->DelView(camview);
+ beauty->DelView(imgview);
+ }
- delete camview;
- delete imgview;
+ delete camview;
+ delete imgview;
}
// +--------------------------------------------------------------------+
@@ -73,68 +73,68 @@ TacRefDlg::~TacRefDlg()
void
TacRefDlg::RegisterControls()
{
- btn_close = (Button*) FindControl(1);
- btn_ships = (Button*) FindControl(101);
- btn_weaps = (Button*) FindControl(102);
- lst_designs = (ListBox*) FindControl(200);
- txt_caption = FindControl(301);
- beauty = FindControl(401);
- txt_stats = (RichTextBox*) FindControl(402);
- txt_description = (RichTextBox*) FindControl(403);
-
- if (btn_close) {
- REGISTER_CLIENT(EID_CLICK, btn_close, TacRefDlg, OnClose);
- }
-
- if (btn_ships) {
- btn_ships->SetButtonState(mode == MODE_SHIPS);
- REGISTER_CLIENT(EID_CLICK, btn_ships, TacRefDlg, OnMode);
- }
-
- if (btn_weaps) {
- btn_weaps->SetButtonState(mode == MODE_WEAPONS);
- REGISTER_CLIENT(EID_CLICK, btn_weaps, TacRefDlg, OnMode);
- }
-
- if (lst_designs) {
- REGISTER_CLIENT(EID_SELECT, lst_designs, TacRefDlg, OnSelect);
- }
-
- if (beauty) {
- REGISTER_CLIENT(EID_RBUTTON_DOWN, beauty, TacRefDlg, OnCamRButtonDown);
- REGISTER_CLIENT(EID_RBUTTON_UP, beauty, TacRefDlg, OnCamRButtonUp);
- REGISTER_CLIENT(EID_MOUSE_MOVE, beauty, TacRefDlg, OnCamMove);
- REGISTER_CLIENT(EID_MOUSE_WHEEL, beauty, TacRefDlg, OnCamZoom);
-
- scene.SetAmbient(Color(60,60,60));
-
- Point light_pos(3e6, 5e6, 4e6);
-
- Light* main_light = new Light(1.0f); //1.25f);
- main_light->MoveTo(light_pos);
- main_light->SetType(Light::LIGHT_DIRECTIONAL);
- main_light->SetColor(Color::White);
- main_light->SetShadow(true);
-
- scene.AddLight(main_light);
-
- Light* back_light = new Light(0.5f);
- back_light->MoveTo(light_pos * -1);
- back_light->SetType(Light::LIGHT_DIRECTIONAL);
- back_light->SetColor(Color::White);
- back_light->SetShadow(false);
-
- scene.AddLight(back_light);
-
- camview = new(__FILE__,__LINE__) CameraView(beauty, &cam, &scene);
- camview->SetProjectionType(Video::PROJECTION_PERSPECTIVE);
- camview->SetFieldOfView(2);
-
- beauty->AddView(camview);
-
- imgview = new(__FILE__,__LINE__) ImgView(beauty, 0);
- imgview->SetBlend(Video::BLEND_ALPHA);
- }
+ btn_close = (Button*) FindControl(1);
+ btn_ships = (Button*) FindControl(101);
+ btn_weaps = (Button*) FindControl(102);
+ lst_designs = (ListBox*) FindControl(200);
+ txt_caption = FindControl(301);
+ beauty = FindControl(401);
+ txt_stats = (RichTextBox*) FindControl(402);
+ txt_description = (RichTextBox*) FindControl(403);
+
+ if (btn_close) {
+ REGISTER_CLIENT(EID_CLICK, btn_close, TacRefDlg, OnClose);
+ }
+
+ if (btn_ships) {
+ btn_ships->SetButtonState(mode == MODE_SHIPS);
+ REGISTER_CLIENT(EID_CLICK, btn_ships, TacRefDlg, OnMode);
+ }
+
+ if (btn_weaps) {
+ btn_weaps->SetButtonState(mode == MODE_WEAPONS);
+ REGISTER_CLIENT(EID_CLICK, btn_weaps, TacRefDlg, OnMode);
+ }
+
+ if (lst_designs) {
+ REGISTER_CLIENT(EID_SELECT, lst_designs, TacRefDlg, OnSelect);
+ }
+
+ if (beauty) {
+ REGISTER_CLIENT(EID_RBUTTON_DOWN, beauty, TacRefDlg, OnCamRButtonDown);
+ REGISTER_CLIENT(EID_RBUTTON_UP, beauty, TacRefDlg, OnCamRButtonUp);
+ REGISTER_CLIENT(EID_MOUSE_MOVE, beauty, TacRefDlg, OnCamMove);
+ REGISTER_CLIENT(EID_MOUSE_WHEEL, beauty, TacRefDlg, OnCamZoom);
+
+ scene.SetAmbient(Color(60,60,60));
+
+ Point light_pos(3e6, 5e6, 4e6);
+
+ Light* main_light = new Light(1.0f); //1.25f);
+ main_light->MoveTo(light_pos);
+ main_light->SetType(Light::LIGHT_DIRECTIONAL);
+ main_light->SetColor(Color::White);
+ main_light->SetShadow(true);
+
+ scene.AddLight(main_light);
+
+ Light* back_light = new Light(0.5f);
+ back_light->MoveTo(light_pos * -1);
+ back_light->SetType(Light::LIGHT_DIRECTIONAL);
+ back_light->SetColor(Color::White);
+ back_light->SetShadow(false);
+
+ scene.AddLight(back_light);
+
+ camview = new(__FILE__,__LINE__) CameraView(beauty, &cam, &scene);
+ camview->SetProjectionType(Video::PROJECTION_PERSPECTIVE);
+ camview->SetFieldOfView(2);
+
+ beauty->AddView(camview);
+
+ imgview = new(__FILE__,__LINE__) ImgView(beauty, 0);
+ imgview->SetBlend(Video::BLEND_ALPHA);
+ }
}
// +--------------------------------------------------------------------+
@@ -142,21 +142,21 @@ TacRefDlg::RegisterControls()
void
TacRefDlg::Show()
{
- update_scene = !shown;
+ update_scene = !shown;
- FormWindow::Show();
+ FormWindow::Show();
- if (update_scene) {
- AWEvent event(btn_ships, EID_CLICK);
- OnMode(&event);
- }
+ if (update_scene) {
+ AWEvent event(btn_ships, EID_CLICK);
+ OnMode(&event);
+ }
}
struct WepGroup {
- Text name;
- int count;
+ Text name;
+ int count;
- WepGroup() : count(0) { }
+ WepGroup() : count(0) { }
};
WepGroup* FindWepGroup(WepGroup* weapons, const char* name);
@@ -164,119 +164,119 @@ WepGroup* FindWepGroup(WepGroup* weapons, const char* name);
void
TacRefDlg::SelectShip(const ShipDesign* design)
{
- if (beauty && camview) {
- scene.Graphics().clear();
-
- if (design) {
- radius = design->radius;
-
- UpdateCamera();
-
- int level = design->lod_levels-1;
- int n = design->models[level].size();
-
- for (int i = 0; i < n; i++) {
- Model* model = design->models[level].at(i);
-
- Solid* s = new(__FILE__,__LINE__) Solid;
- s->UseModel(model);
- s->CreateShadows(1);
- s->MoveTo(*design->offsets[level].at(i));
-
- scene.Graphics().append(s);
- }
- }
- }
-
- if (txt_caption) {
- txt_caption->SetText("");
-
- if (design) {
- char txt[256];
- sprintf(txt, "%s %s", design->abrv, design->DisplayName());
- txt_caption->SetText(txt);
- }
- }
-
- if (txt_stats) {
- txt_stats->SetText("");
-
- if (design) {
- Text desc;
- char txt[256];
-
- sprintf(txt, "%s\t\t\t%s\n", Game::GetText("tacref.type").data(), Ship::ClassName(design->type));
- desc += txt;
-
- sprintf(txt, "%s\t\t\t%s\n", Game::GetText("tacref.class").data(), design->DisplayName());
- desc += txt;
- desc += Game::GetText("tacref.length");
- desc += "\t\t";
-
- if (design->type < Ship::STATION)
- FormatNumber(txt, design->radius/2);
- else
- FormatNumber(txt, design->radius*2);
-
- strcat(txt, " m\n");
- desc += txt;
- desc += Game::GetText("tacref.mass");
- desc += "\t\t\t";
-
- FormatNumber(txt, design->mass);
- strcat(txt, " T\n");
- desc += txt;
- desc += Game::GetText("tacref.hull");
- desc += "\t\t\t";
-
- FormatNumber(txt, design->integrity);
- strcat(txt, "\n");
- desc += txt;
-
- if (design->weapons.size()) {
- desc += Game::GetText("tacref.weapons");
-
- WepGroup groups[8];
- for (int w = 0; w < design->weapons.size(); w++) {
- Weapon* gun = design->weapons[w];
- WepGroup* group = FindWepGroup(groups, gun->Group());
-
- if (group)
- group->count++;
- }
-
- for (int g = 0; g < 8; g++) {
- WepGroup* group = &groups[g];
- if (group && group->count) {
- sprintf(txt, "\t\t%s (%d)\n\t\t", group->name.data(), group->count);
- desc += txt;
-
- for (int w = 0; w < design->weapons.size(); w++) {
- Weapon* gun = design->weapons[w];
-
- if (group->name == gun->Group()) {
- sprintf(txt, "\t\t\t%s\n\t\t", (const char*) gun->Design()->name);
- desc += txt;
- }
- }
- }
- }
-
- desc += "\n";
- }
-
- txt_stats->SetText(desc);
- }
- }
-
- if (txt_description) {
- if (design && design->description.length()) {
- txt_description->SetText(design->description);
- }
- else {
- txt_description->SetText(Game::GetText("tacref.mass"));
- }
- }
+ if (beauty && camview) {
+ scene.Graphics().clear();
+
+ if (design) {
+ radius = design->radius;
+
+ UpdateCamera();
+
+ int level = design->lod_levels-1;
+ int n = design->models[level].size();
+
+ for (int i = 0; i < n; i++) {
+ Model* model = design->models[level].at(i);
+
+ Solid* s = new(__FILE__,__LINE__) Solid;
+ s->UseModel(model);
+ s->CreateShadows(1);
+ s->MoveTo(*design->offsets[level].at(i));
+
+ scene.Graphics().append(s);
+ }
+ }
+ }
+
+ if (txt_caption) {
+ txt_caption->SetText("");
+
+ if (design) {
+ char txt[256];
+ sprintf(txt, "%s %s", design->abrv, design->DisplayName());
+ txt_caption->SetText(txt);
+ }
+ }
+
+ if (txt_stats) {
+ txt_stats->SetText("");
+
+ if (design) {
+ Text desc;
+ char txt[256];
+
+ sprintf(txt, "%s\t\t\t%s\n", Game::GetText("tacref.type").data(), Ship::ClassName(design->type));
+ desc += txt;
+
+ sprintf(txt, "%s\t\t\t%s\n", Game::GetText("tacref.class").data(), design->DisplayName());
+ desc += txt;
+ desc += Game::GetText("tacref.length");
+ desc += "\t\t";
+
+ if (design->type < Ship::STATION)
+ FormatNumber(txt, design->radius/2);
+ else
+ FormatNumber(txt, design->radius*2);
+
+ strcat(txt, " m\n");
+ desc += txt;
+ desc += Game::GetText("tacref.mass");
+ desc += "\t\t\t";
+
+ FormatNumber(txt, design->mass);
+ strcat(txt, " T\n");
+ desc += txt;
+ desc += Game::GetText("tacref.hull");
+ desc += "\t\t\t";
+
+ FormatNumber(txt, design->integrity);
+ strcat(txt, "\n");
+ desc += txt;
+
+ if (design->weapons.size()) {
+ desc += Game::GetText("tacref.weapons");
+
+ WepGroup groups[8];
+ for (int w = 0; w < design->weapons.size(); w++) {
+ Weapon* gun = design->weapons[w];
+ WepGroup* group = FindWepGroup(groups, gun->Group());
+
+ if (group)
+ group->count++;
+ }
+
+ for (int g = 0; g < 8; g++) {
+ WepGroup* group = &groups[g];
+ if (group && group->count) {
+ sprintf(txt, "\t\t%s (%d)\n\t\t", group->name.data(), group->count);
+ desc += txt;
+
+ for (int w = 0; w < design->weapons.size(); w++) {
+ Weapon* gun = design->weapons[w];
+
+ if (group->name == gun->Group()) {
+ sprintf(txt, "\t\t\t%s\n\t\t", (const char*) gun->Design()->name);
+ desc += txt;
+ }
+ }
+ }
+ }
+
+ desc += "\n";
+ }
+
+ txt_stats->SetText(desc);
+ }
+ }
+
+ if (txt_description) {
+ if (design && design->description.length()) {
+ txt_description->SetText(design->description);
+ }
+ else {
+ txt_description->SetText(Game::GetText("tacref.mass"));
+ }
+ }
}
// +--------------------------------------------------------------------+
@@ -284,139 +284,139 @@ TacRefDlg::SelectShip(const ShipDesign* design)
void
TacRefDlg::SelectWeapon(const WeaponDesign* design)
{
- if (beauty && imgview) {
- imgview->SetPicture(0);
-
- if (design)
- imgview->SetPicture(design->beauty_img);
- }
-
- if (txt_caption) {
- txt_caption->SetText("");
-
- if (design)
- txt_caption->SetText(design->name);
- }
-
- if (txt_stats) {
- txt_stats->SetText("");
-
- if (design) {
- Text desc;
- char txt[256];
-
- desc = Game::GetText("tacref.name");
- desc += "\t";
- desc += design->name;
- desc += "\n";
- desc += Game::GetText("tacref.type");
- desc += "\t\t";
-
- if (design->damage < 1)
- desc += Game::GetText("tacref.wep.other");
- else if (design->beam)
- desc += Game::GetText("tacref.wep.beam");
- else if (design->primary)
- desc += Game::GetText("tacref.wep.bolt");
- else if (design->drone)
- desc += Game::GetText("tacref.wep.drone");
- else if (design->guided)
- desc += Game::GetText("tacref.wep.guided");
- else
- desc += Game::GetText("tacref.wep.missile");
-
- if (design->turret_model && design->damage >= 1) {
- desc += " ";
- desc += Game::GetText("tacref.wep.turret");
- desc += "\n";
- }
- else {
- desc += "\n";
- }
-
- desc += Game::GetText("tacref.targets");
- desc += "\t";
-
- if ((design->target_type & Ship::DROPSHIPS) != 0) {
- if ((design->target_type & Ship::STARSHIPS) != 0) {
- if ((design->target_type & Ship::GROUND_UNITS) != 0) {
- desc += Game::GetText("tacref.targets.fsg");
- }
- else {
- desc += Game::GetText("tacref.targets.fs");
- }
- }
- else {
- if ((design->target_type & Ship::GROUND_UNITS) != 0) {
- desc += Game::GetText("tacref.targets.fg");
- }
- else {
- desc += Game::GetText("tacref.targets.f");
- }
- }
- }
-
- else if ((design->target_type & Ship::STARSHIPS) != 0) {
- if ((design->target_type & Ship::GROUND_UNITS) != 0) {
- desc += Game::GetText("tacref.targets.sg");
- }
- else {
- desc += Game::GetText("tacref.targets.s");
- }
- }
-
- else if ((design->target_type & Ship::GROUND_UNITS) != 0) {
- desc += Game::GetText("tacref.targets.g");
- }
-
- desc += "\n";
- desc += Game::GetText("tacref.speed");
- desc += "\t";
-
- FormatNumber(txt, design->speed);
- desc += txt;
- desc += "m/s\n";
- desc += Game::GetText("tacref.range");
- desc += "\t";
-
- FormatNumber(txt, design->max_range);
- desc += txt;
- desc += "m\n";
- desc += Game::GetText("tacref.damage");
- desc += "\t";
-
- if (design->damage > 0) {
- FormatNumber(txt, design->damage * design->charge);
- desc += txt;
- if (design->beam)
- desc += "/s";
- }
- else {
- desc += Game::GetText("tacref.none");
- }
-
- desc += "\n";
-
- if (!design->primary && design->damage > 0) {
- desc += Game::GetText("tacref.kill-radius");
- desc += "\t";
- FormatNumber(txt, design->lethal_radius);
- desc += txt;
- desc += " m\n";
- }
-
- txt_stats->SetText(desc);
- }
- }
-
- if (txt_description) {
- if (design && design->description.length()) {
- txt_description->SetText(design->description);
- }
- else {
- txt_description->SetText(Game::GetText("tacref.no-info"));
- }
- }
+ if (beauty && imgview) {
+ imgview->SetPicture(0);
+
+ if (design)
+ imgview->SetPicture(design->beauty_img);
+ }
+
+ if (txt_caption) {
+ txt_caption->SetText("");
+
+ if (design)
+ txt_caption->SetText(design->name);
+ }
+
+ if (txt_stats) {
+ txt_stats->SetText("");
+
+ if (design) {
+ Text desc;
+ char txt[256];
+
+ desc = Game::GetText("tacref.name");
+ desc += "\t";
+ desc += design->name;
+ desc += "\n";
+ desc += Game::GetText("tacref.type");
+ desc += "\t\t";
+
+ if (design->damage < 1)
+ desc += Game::GetText("tacref.wep.other");
+ else if (design->beam)
+ desc += Game::GetText("tacref.wep.beam");
+ else if (design->primary)
+ desc += Game::GetText("tacref.wep.bolt");
+ else if (design->drone)
+ desc += Game::GetText("tacref.wep.drone");
+ else if (design->guided)
+ desc += Game::GetText("tacref.wep.guided");
+ else
+ desc += Game::GetText("tacref.wep.missile");
+
+ if (design->turret_model && design->damage >= 1) {
+ desc += " ";
+ desc += Game::GetText("tacref.wep.turret");
+ desc += "\n";
+ }
+ else {
+ desc += "\n";
+ }
+
+ desc += Game::GetText("tacref.targets");
+ desc += "\t";
+
+ if ((design->target_type & Ship::DROPSHIPS) != 0) {
+ if ((design->target_type & Ship::STARSHIPS) != 0) {
+ if ((design->target_type & Ship::GROUND_UNITS) != 0) {
+ desc += Game::GetText("tacref.targets.fsg");
+ }
+ else {
+ desc += Game::GetText("tacref.targets.fs");
+ }
+ }
+ else {
+ if ((design->target_type & Ship::GROUND_UNITS) != 0) {
+ desc += Game::GetText("tacref.targets.fg");
+ }
+ else {
+ desc += Game::GetText("tacref.targets.f");
+ }
+ }
+ }
+
+ else if ((design->target_type & Ship::STARSHIPS) != 0) {
+ if ((design->target_type & Ship::GROUND_UNITS) != 0) {
+ desc += Game::GetText("tacref.targets.sg");
+ }
+ else {
+ desc += Game::GetText("tacref.targets.s");
+ }
+ }
+
+ else if ((design->target_type & Ship::GROUND_UNITS) != 0) {
+ desc += Game::GetText("tacref.targets.g");
+ }
+
+ desc += "\n";
+ desc += Game::GetText("tacref.speed");
+ desc += "\t";
+
+ FormatNumber(txt, design->speed);
+ desc += txt;
+ desc += "m/s\n";
+ desc += Game::GetText("tacref.range");
+ desc += "\t";
+
+ FormatNumber(txt, design->max_range);
+ desc += txt;
+ desc += "m\n";
+ desc += Game::GetText("tacref.damage");
+ desc += "\t";
+
+ if (design->damage > 0) {
+ FormatNumber(txt, design->damage * design->charge);
+ desc += txt;
+ if (design->beam)
+ desc += "/s";
+ }
+ else {
+ desc += Game::GetText("tacref.none");
+ }
+
+ desc += "\n";
+
+ if (!design->primary && design->damage > 0) {
+ desc += Game::GetText("tacref.kill-radius");
+ desc += "\t";
+ FormatNumber(txt, design->lethal_radius);
+ desc += txt;
+ desc += " m\n";
+ }
+
+ txt_stats->SetText(desc);
+ }
+ }
+
+ if (txt_description) {
+ if (design && design->description.length()) {
+ txt_description->SetText(design->description);
+ }
+ else {
+ txt_description->SetText(Game::GetText("tacref.no-info"));
+ }
+ }
}
// +--------------------------------------------------------------------+
@@ -431,21 +431,21 @@ TacRefDlg::ExecFrame()
bool
TacRefDlg::SetCaptureBeauty()
{
- EventDispatch* dispatch = EventDispatch::GetInstance();
- if (dispatch && beauty)
- return dispatch->CaptureMouse(beauty) ? true : false;
+ EventDispatch* dispatch = EventDispatch::GetInstance();
+ if (dispatch && beauty)
+ return dispatch->CaptureMouse(beauty) ? true : false;
- return 0;
+ return 0;
}
bool
TacRefDlg::ReleaseCaptureBeauty()
{
- EventDispatch* dispatch = EventDispatch::GetInstance();
- if (dispatch && beauty)
- return dispatch->ReleaseMouse(beauty) ? true : false;
+ EventDispatch* dispatch = EventDispatch::GetInstance();
+ if (dispatch && beauty)
+ return dispatch->ReleaseMouse(beauty) ? true : false;
- return 0;
+ return 0;
}
// +--------------------------------------------------------------------+
@@ -453,48 +453,48 @@ TacRefDlg::ReleaseCaptureBeauty()
void
TacRefDlg::UpdateAzimuth(double a)
{
- cam_az += a;
-
- if (cam_az > PI)
- cam_az = -2*PI + cam_az;
+ cam_az += a;
- else if (cam_az < -PI)
- cam_az = 2*PI + cam_az;
+ if (cam_az > PI)
+ cam_az = -2*PI + cam_az;
+
+ else if (cam_az < -PI)
+ cam_az = 2*PI + cam_az;
}
void
TacRefDlg::UpdateElevation(double e)
{
- cam_el += e;
+ cam_el += e;
- const double limit = (0.43 * PI);
+ const double limit = (0.43 * PI);
- if (cam_el > limit)
- cam_el = limit;
- else if (cam_el < -limit)
- cam_el = -limit;
+ if (cam_el > limit)
+ cam_el = limit;
+ else if (cam_el < -limit)
+ cam_el = -limit;
}
void
TacRefDlg::UpdateZoom(double delta)
{
- cam_zoom *= delta;
+ cam_zoom *= delta;
- if (cam_zoom < 1.2)
- cam_zoom = 1.2;
+ if (cam_zoom < 1.2)
+ cam_zoom = 1.2;
- else if (cam_zoom > 10)
- cam_zoom = 10;
+ else if (cam_zoom > 10)
+ cam_zoom = 10;
}
void
TacRefDlg::UpdateCamera()
{
- double x = cam_zoom * radius * sin(cam_az) * cos(cam_el);
- double y = cam_zoom * radius * cos(cam_az) * cos(cam_el);
- double z = cam_zoom * radius * sin(cam_el);
+ double x = cam_zoom * radius * sin(cam_az) * cos(cam_el);
+ double y = cam_zoom * radius * cos(cam_az) * cos(cam_el);
+ double z = cam_zoom * radius * sin(cam_el);
- cam.LookAt(Point(0,0,0), Point(x,z,y), Point(0,1,0));
+ cam.LookAt(Point(0,0,0), Point(x,z,y), Point(0,1,0));
}
// +--------------------------------------------------------------------+
@@ -502,26 +502,26 @@ TacRefDlg::UpdateCamera()
void
TacRefDlg::OnSelect(AWEvent* event)
{
- if (lst_designs) {
- int seln = lst_designs->GetSelection();
- DWORD dsn = lst_designs->GetItemData(seln);
-
- if (mode == MODE_SHIPS) {
- ship_index = seln;
-
- if (dsn) {
- SelectShip((ShipDesign*) dsn);
- }
- }
-
- else if (mode == MODE_WEAPONS) {
- weap_index = seln;
-
- if (dsn) {
- SelectWeapon((WeaponDesign*) dsn);
- }
- }
- }
+ if (lst_designs) {
+ int seln = lst_designs->GetSelection();
+ DWORD dsn = lst_designs->GetItemData(seln);
+
+ if (mode == MODE_SHIPS) {
+ ship_index = seln;
+
+ if (dsn) {
+ SelectShip((ShipDesign*) dsn);
+ }
+ }
+
+ else if (mode == MODE_WEAPONS) {
+ weap_index = seln;
+
+ if (dsn) {
+ SelectWeapon((WeaponDesign*) dsn);
+ }
+ }
+ }
}
// +--------------------------------------------------------------------+
@@ -529,57 +529,57 @@ TacRefDlg::OnSelect(AWEvent* event)
void
TacRefDlg::OnCamRButtonDown(AWEvent* event)
{
- captured = SetCaptureBeauty();
- mouse_x = event->x;
- mouse_y = event->y;
+ captured = SetCaptureBeauty();
+ mouse_x = event->x;
+ mouse_y = event->y;
}
void
TacRefDlg::OnCamRButtonUp(AWEvent* event)
{
- if (captured)
- ReleaseCaptureBeauty();
+ if (captured)
+ ReleaseCaptureBeauty();
- captured = false;
- mouse_x = 0;
- mouse_y = 0;
+ captured = false;
+ mouse_x = 0;
+ mouse_y = 0;
}
void
TacRefDlg::OnCamMove(AWEvent* event)
{
- if (captured) {
- int mouse_dx = event->x - mouse_x;
- int mouse_dy = event->y - mouse_y;
+ if (captured) {
+ int mouse_dx = event->x - mouse_x;
+ int mouse_dy = event->y - mouse_y;
- UpdateAzimuth( mouse_dx * 0.3 * DEGREES);
- UpdateElevation( mouse_dy * 0.3 * DEGREES);
- UpdateCamera();
+ UpdateAzimuth( mouse_dx * 0.3 * DEGREES);
+ UpdateElevation( mouse_dy * 0.3 * DEGREES);
+ UpdateCamera();
- mouse_x = event->x;
- mouse_y = event->y;
- }
+ mouse_x = event->x;
+ mouse_y = event->y;
+ }
}
void
TacRefDlg::OnCamZoom(AWEvent* event)
{
- int w = Mouse::Wheel();
-
- if (w < 0) {
- while (w < 0) {
- UpdateZoom(1.25);
- w += 120;
- }
- }
- else {
- while (w > 0) {
- UpdateZoom(0.75f);
- w -= 120;
- }
- }
-
- UpdateCamera();
+ int w = Mouse::Wheel();
+
+ if (w < 0) {
+ while (w < 0) {
+ UpdateZoom(1.25);
+ w += 120;
+ }
+ }
+ else {
+ while (w > 0) {
+ UpdateZoom(0.75f);
+ w -= 120;
+ }
+ }
+
+ UpdateCamera();
}
// +--------------------------------------------------------------------+
@@ -587,96 +587,96 @@ TacRefDlg::OnCamZoom(AWEvent* event)
void
TacRefDlg::OnMode(AWEvent* event)
{
- if (event->window == btn_ships && mode != MODE_SHIPS) {
- mode = MODE_SHIPS;
+ if (event->window == btn_ships && mode != MODE_SHIPS) {
+ mode = MODE_SHIPS;
- if (lst_designs) {
- lst_designs->ClearItems();
+ if (lst_designs) {
+ lst_designs->ClearItems();
- List<Text> designs;
+ List<Text> designs;
- for (int n = 0; n < 16; n++) {
- int type = 1 << n;
- ShipDesign::GetDesignList(type, designs);
+ for (int n = 0; n < 16; n++) {
+ int type = 1 << n;
+ ShipDesign::GetDesignList(type, designs);
- ListIter<Text> iter = designs;
- while (++iter) {
- Text* val = iter.value();
+ ListIter<Text> iter = designs;
+ while (++iter) {
+ Text* val = iter.value();
- const ShipDesign* dsn = ShipDesign::Get(*val);
+ const ShipDesign* dsn = ShipDesign::Get(*val);
- if (dsn) {
- char txt[256];
- sprintf(txt, "%s %s", dsn->abrv, dsn->DisplayName());
+ if (dsn) {
+ char txt[256];
+ sprintf(txt, "%s %s", dsn->abrv, dsn->DisplayName());
- lst_designs->AddItemWithData(txt, (DWORD) dsn);
- }
- else {
- lst_designs->AddItemWithData(*val, 0);
- }
- }
- }
+ lst_designs->AddItemWithData(txt, (DWORD) dsn);
+ }
+ else {
+ lst_designs->AddItemWithData(*val, 0);
+ }
+ }
+ }
- lst_designs->SetSelected(ship_index);
- }
+ lst_designs->SetSelected(ship_index);
+ }
- if (beauty) {
- beauty->AddView(camview);
- beauty->DelView(imgview);
- }
+ if (beauty) {
+ beauty->AddView(camview);
+ beauty->DelView(imgview);
+ }
- DWORD dsn = lst_designs->GetItemData(ship_index);
+ DWORD dsn = lst_designs->GetItemData(ship_index);
- if (dsn) {
- SelectShip((ShipDesign*) dsn);
- }
- }
+ if (dsn) {
+ SelectShip((ShipDesign*) dsn);
+ }
+ }
- else if (event->window == btn_weaps && mode != MODE_WEAPONS) {
- mode = MODE_WEAPONS;
+ else if (event->window == btn_weaps && mode != MODE_WEAPONS) {
+ mode = MODE_WEAPONS;
- const WeaponDesign* design = 0;
+ const WeaponDesign* design = 0;
- if (lst_designs) {
- lst_designs->ClearItems();
- List<Text> designs;
+ if (lst_designs) {
+ lst_designs->ClearItems();
+ List<Text> designs;
- WeaponDesign::GetDesignList(designs);
+ WeaponDesign::GetDesignList(designs);
- ListIter<Text> iter = designs;
- while (++iter) {
- Text* val = iter.value();
+ ListIter<Text> iter = designs;
+ while (++iter) {
+ Text* val = iter.value();
- if (val->contains("Zolon") || val->contains("Inverted"))
- continue;
+ if (val->contains("Zolon") || val->contains("Inverted"))
+ continue;
- const WeaponDesign* dsn = WeaponDesign::Find(*val);
+ const WeaponDesign* dsn = WeaponDesign::Find(*val);
- if (dsn && !dsn->secret) {
- lst_designs->AddItemWithData(*val, (DWORD) dsn);
+ if (dsn && !dsn->secret) {
+ lst_designs->AddItemWithData(*val, (DWORD) dsn);
- if (!design)
- design = dsn;
- }
- }
+ if (!design)
+ design = dsn;
+ }
+ }
- lst_designs->SetSelected(weap_index);
- }
+ lst_designs->SetSelected(weap_index);
+ }
- if (beauty) {
- beauty->DelView(camview);
- beauty->AddView(imgview);
- }
+ if (beauty) {
+ beauty->DelView(camview);
+ beauty->AddView(imgview);
+ }
- DWORD dsn = lst_designs->GetItemData(weap_index);
+ DWORD dsn = lst_designs->GetItemData(weap_index);
- if (dsn) {
- SelectWeapon((WeaponDesign*) dsn);
- }
- }
+ if (dsn) {
+ SelectWeapon((WeaponDesign*) dsn);
+ }
+ }
- btn_ships->SetButtonState(mode == MODE_SHIPS);
- btn_weaps->SetButtonState(mode == MODE_WEAPONS);
+ btn_ships->SetButtonState(mode == MODE_SHIPS);
+ btn_weaps->SetButtonState(mode == MODE_WEAPONS);
}
// +--------------------------------------------------------------------+
@@ -684,6 +684,6 @@ TacRefDlg::OnMode(AWEvent* event)
void
TacRefDlg::OnClose(AWEvent* event)
{
- manager->ShowMenuDlg();
+ manager->ShowMenuDlg();
}