summaryrefslogtreecommitdiffhomepage
path: root/Stars45/ModInfoDlg.cpp
blob: f7dfb34b0cec243063aa4c5cf9e2296ae63c7bd6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*  Project Starshatter 4.5
    Destroyer Studios LLC
    Copyright © 1997-2004. All Rights Reserved.

    SUBSYSTEM:    Stars.exe
    FILE:         ModInfoDlg.cpp
    AUTHOR:       John DiCamillo


    OVERVIEW
    ========
    Mod Config Dialog Active Window class
*/

#include "MemDebug.h"
#include "ModInfoDlg.h"
#include "BaseScreen.h"
#include "ModConfig.h"
#include "ModInfo.h"

#include "Game.h"
#include "DataLoader.h"
#include "Button.h"
#include "ListBox.h"
#include "ImageBox.h"
#include "Video.h"
#include "Keyboard.h"
#include "Mouse.h"
#include "ParseUtil.h"

// +--------------------------------------------------------------------+
// DECLARE MAPPING FUNCTIONS:

DEF_MAP_CLIENT(ModInfoDlg, OnAccept);

// +--------------------------------------------------------------------+

ModInfoDlg::ModInfoDlg(Screen* s, FormDef& def, BaseScreen* mgr)
   : FormWindow(s,  0,  0, s->Width(), s->Height()), manager(mgr),
     btn_accept(0), mod_info(0)
{
   Init(def);
}

ModInfoDlg::~ModInfoDlg()
{
}

// +--------------------------------------------------------------------+

void
ModInfoDlg::RegisterControls()
{
   btn_accept     = (Button*) FindControl(  1);

   if (btn_accept)
      REGISTER_CLIENT(EID_CLICK,    btn_accept,    ModInfoDlg, OnAccept);

   lbl_name       = FindControl(101);
   lbl_desc       = FindControl(102);
   lbl_copy       = FindControl(103);

   img_logo       = (ImageBox*) FindControl(200);

   if (img_logo) {
      img_logo->GetPicture(bmp_default);
      img_logo->SetBlendMode(Video::BLEND_SOLID);
   }
}

// +--------------------------------------------------------------------+

void
ModInfoDlg::Show()
{
   FormWindow::Show();
}

// +--------------------------------------------------------------------+

void
ModInfoDlg::ExecFrame()
{
   if (Keyboard::KeyDown(VK_RETURN)) {
      if (btn_accept && btn_accept->IsEnabled())
         OnAccept(0);
   }
}

// +--------------------------------------------------------------------+

void
ModInfoDlg::SetModInfo(ModInfo* info)
{
   mod_info = info;

   if (mod_info) {
      if (lbl_name)  lbl_name->SetText(mod_info->Name());
      if (lbl_desc)  lbl_desc->SetText(mod_info->Description());
      if (lbl_copy)  lbl_copy->SetText(mod_info->Copyright());

      if (img_logo && mod_info->LogoImage() && mod_info->LogoImage()->Width() > 32)
         img_logo->SetPicture(*mod_info->LogoImage());
      else if (img_logo)
         img_logo->SetPicture(bmp_default);
   }
}

// +--------------------------------------------------------------------+

void
ModInfoDlg::OnAccept(AWEvent* event)
{
   manager->ShowModDlg();
}