Debian Codegraph @

Descent3/mmItem.h

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 --- HISTORICAL COMMENTS FOLLOW ---
19
20 * $Source: $
21 * $Revision: 14 $
22 * $Author: Kevin $
23 * $Date: 7/28/99 4:01p $
24 *
25 * main menu user interface items
26 *
27 * $Log: /DescentIII/main/mmItem.h $
28 *
29 * 14 7/28/99 4:01p Kevin
30 * Mac
31 *
32 * 13 4/29/99 3:21a Samir
33 * reorganized main menu music to work in config, multiplayer, whereever.
34 *
35 * 12 4/15/99 2:32p Kevin
36 * Added some code for the Demo
37 *
38 * 11 4/15/99 1:40a Jeff
39 * changes for linux compile
40 *
41 * 10 4/02/99 3:03p Samir
42 * opengl doesn't use main menu movie.
43 *
44 * 9 3/18/99 10:13a Samir
45 * new main menu interface.
46 *
47 * 8 2/26/99 5:34p Samir
48 * oem screen.
49 *
50 * 7 10/22/98 12:46a Matt
51 * Made MenuScene() public.
52 *
53 * 6 10/20/98 6:24p Samir
54 * moved menu down.
55 *
56 * 5 10/20/98 3:52p Samir
57 * tweaked main menu look.
58 *
59 * 4 10/13/98 3:16p Samir
60 * enhanced gadgets some more with new effects (added Credits option).
61 *
62 * 3 10/12/98 4:40p Samir
63 * fancy effect for hotspots in main menu.
64 *
65 * 2 10/12/98 1:46p Samir
66 * initial new main menu
67 *
68 */
69 #ifndef MMITEM_H
70 #define MMITEM_H
71
72 #include "cinematics.h"
73 #include "gamefont.h"
74 #include "newui.h"
75 #include "psclass.h"
76
77 #if ((!defined(OEM)) && (!defined(DEMO)))
78 #define MOVIE_MENU
79 #endif
80 #define MMITEM_ALPHA 192 // default alpha
81 #define MMITEM_SAT 0 // default saturation
82 #define MMITEM_FONT MENU_FONT // default font
83 #define MMITEM_COLOR GR_RGB(255, 255, 255) // default color of main menu
84 #define MMITEM_X (Max_window_w * 3 / 5) // x position of menu text
85 #define MMITEM_Y 175 // y position of menu text start
86 #define N_MMENU_ITEMS 10 // modify this value to set the maximum main menu items avail.
87 #define MM_STARTMENU_TYPE 1 // start menu group (used in mmInterface::AddITem)
88 #define MM_ENDMENU_TYPE 2 // end menu group
89 // main menu sounds
90 #define N_MM_SOUNDS 2
91 #define MM_SELECT_SOUND 0
92 #define MM_FOCUS_SOUND 1
93 // main menu music
94 #define MM_MUSIC_REGION 0
95 #define NEWGAME_MUSIC_REGION 1
96 #define OPTIONS_MUSIC_REGION 2
97 #define MULTI_MUSIC_REGION 3
98 // mmItem FX list.
99 enum tmmItemFX {
100 mmItemFXNull,
101 mmItemFXNormal, // displays item with normal alpha, color, saturation.
102 mmItemFXFadeInToBright,
103 mmItemFXFadeOutToNormal // fade in and out to and from brighten
104 };
105
106 void MenuScene(); // display menu scene
107 /////////////////////////////////////////////////////////////////////
108 // gcc doesn't like the tQueue template in psclass.h
109 #if defined(POSIX)
110 // tQueue
111 // a circular queue implementation
112 class tmmItemQueue {
113 #define tmmItemSIZE 8
114 tmmItemFX m_items[tmmItemSIZE];
115 int16_t m_head, m_tail;
116
117 public:
118 tmmItemQueue() { m_head = m_tail = 0; };
119 ~tmmItemQueue(){};
120 void send(tmmItemFX &item) { // sends an item onto the queue
121 int16_t temp = m_tail + 1;
122 if (temp == tmmItemSIZE)
123 temp = 0;
124 if (temp != m_head) {
125 m_items[m_tail] = item;
126 m_tail = temp;
127 }
128 };
129 bool recv(tmmItemFX *item) { // returns an item from the queue, false if no item.
130 if (m_head == m_tail)
131 return false;
132 *item = m_items[m_head++];
133 if (m_head == tmmItemSIZE)
134 m_head = 0;
135 return true;
136 };
137 void flush() { // flush queue entries.
138 m_head = m_tail = 0;
139 };
140 };
141 #endif
142 //////////////////////////////////////////////////////////////////////
143 class mmInterface;
144 // class mmItem
145 class mmItem : public UIGadget {
146 char *m_text; // text for item
147 int16_t m_alpha; // alpha for text item
148 int16_t m_satcount;
149 tmmItemFX m_curfx; // current effect
150 #if !defined(POSIX)
151 tQueue<tmmItemFX, 8> m_fxqueue; // special effects queue
152 #else
153 tmmItemQueue m_fxqueue;
154 #endif
155 ddgr_color m_colors[6]; // colors for menu (4 corners and 2 mid points)
156 float m_process_speed; // speed gadget is processed (state changes, etc every x seconds)
157 float m_last_frametime; // last frame's time.
158 static mmInterface *m_window; // attached window
159 public:
160 mmItem();
161 virtual ~mmItem();
162
163 public:
164 // attaches a window to all mmitems.
165 static void AttachInterface(mmInterface *wnd);
166 void Create(int id, int key, int x, int y, const char *text, int flags, tmmItemFX init_fx = mmItemFXNormal);
167 void AddEffect(tmmItemFX fx);
168 void ClearEffects();
169
170 protected:
171 virtual void OnMouseBtnDown(int btn); // override: behavior when mouse button is pressed.
172 virtual void OnMouseBtnUp(int btn); // override: behavior when mouse button is released.
173 virtual void OnFormat(); // override: called when resized or before drawing.
174 virtual void OnDraw(); // override: behavior when gadget is being drawn.
175 virtual void OnLostFocus(); // override: behavior when gadget loses input focus.
176 virtual void OnGainFocus(); // override: behavior when gadget gains input focus.
177 virtual void OnDestroy(); // override: behavior when gadget is destroyed.
178 virtual void OnUserProcess(); // override: behavior when gadget is processed
179 virtual void OnSelect();
180 };
181 // Main Menu Interface Object
182
183 class mmInterface : public UIWindow {
184 int m_nmenu_items; // number of menu items available.
185 mmItem m_menuitems[N_MMENU_ITEMS]; // main menu items
186 #ifdef MOVIE_MENU
187 tCinematic *m_movie; // menu movie handle
188 #endif
189 tLargeBitmap m_art; // artwork for the bitmap
190 public:
191 // type MM_STARTMENU_TYPE = start, type MM_ENDMENU_TYPE = end, (1+2) = start and end, type 0 = normal
192 bool AddItem(int id, int key, const char *text, int type = 0);
193 void Create();
194 int DoUI(); // does user interface.
195 public:
196 int SoundHandles[N_MM_SOUNDS];
197 void SetMusicRegion(int region);
198 friend void MenuScene(); // display menu scene
199 protected:
200 virtual void OnDestroy(); // destroys window.
201 private:
202 void CopyrightText(); // displays the copyright text
203 };
204 #endif