| 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_Hcxx . . $ `Descent3/mmItem.h:70:9`! |
| 71 | |
| 72 | #include "cinematics.h"cxx . . $ `<file>/Descent3/cinematics.h`/ |
| 73 | #include "gamefont.h"cxx . . $ `<file>/Descent3/gamefont.h`/ |
| 74 | #include "newui.h"cxx . . $ `<file>/Descent3/newui.h`/ |
| 75 | #include "psclass.h"cxx . . $ `<file>/lib/psclass.h`/ |
| 76 | |
| 77 | #if ((!defined(OEM)) && (!defined(DEMO))) |
| 78 | #define MOVIE_MENUcxx . . $ `Descent3/mmItem.h:78:9`! |
| 79 | #endif |
| 80 | #define MMITEM_ALPHAcxx . . $ `Descent3/mmItem.h:80:9`! 192 // default alpha |
| 81 | #define MMITEM_SATcxx . . $ `Descent3/mmItem.h:81:9`! 0 // default saturation |
| 82 | #define MMITEM_FONTcxx . . $ `Descent3/mmItem.h:82:9`! MENU_FONTcxx . . $ `Descent3/gamefont.h:106:9`! // default font |
| 83 | #define MMITEM_COLORcxx . . $ `Descent3/mmItem.h:83:9`! GR_RGB(255, 255, 255) // default color of main menu |
| 84 | #define MMITEM_Xcxx . . $ `Descent3/mmItem.h:84:9`! (Max_window_w * 3 / 5) // x position of menu text |
| 85 | #define MMITEM_Ycxx . . $ `Descent3/mmItem.h:85:9`! 175 // y position of menu text start |
| 86 | #define N_MMENU_ITEMScxx . . $ `Descent3/mmItem.h:86:9`! 10 // modify this value to set the maximum main menu items avail. |
| 87 | #define MM_STARTMENU_TYPEcxx . . $ `Descent3/mmItem.h:87:9`! 1 // start menu group (used in mmInterface::AddITem) |
| 88 | #define MM_ENDMENU_TYPEcxx . . $ `Descent3/mmItem.h:88:9`! 2 // end menu group |
| 89 | // main menu sounds |
| 90 | #define N_MM_SOUNDScxx . . $ `Descent3/mmItem.h:90:9`! 2 |
| 91 | #define MM_SELECT_SOUNDcxx . . $ `Descent3/mmItem.h:91:9`! 0 |
| 92 | #define MM_FOCUS_SOUNDcxx . . $ `Descent3/mmItem.h:92:9`! 1 |
| 93 | // main menu music |
| 94 | #define MM_MUSIC_REGIONcxx . . $ `Descent3/mmItem.h:94:9`! 0 |
| 95 | #define NEWGAME_MUSIC_REGIONcxx . . $ `Descent3/mmItem.h:95:9`! 1 |
| 96 | #define OPTIONS_MUSIC_REGIONcxx . . $ `Descent3/mmItem.h:96:9`! 2 |
| 97 | #define MULTI_MUSIC_REGIONcxx . . $ `Descent3/mmItem.h:97:9`! 3 |
| 98 | // mmItem FX list. |
| 99 | enum tmmItemFXcxx . . $ tmmItemFX# { |
| 100 | mmItemFXNullcxx . . $ mmItemFXNull., |
| 101 | mmItemFXNormalcxx . . $ mmItemFXNormal., // displays item with normal alpha, color, saturation. |
| 102 | mmItemFXFadeInToBrightcxx . . $ mmItemFXFadeInToBright., |
| 103 | mmItemFXFadeOutToNormalcxx . . $ mmItemFXFadeOutToNormal. // fade in and out to and from brighten |
| 104 | }; |
| 105 | |
| 106 | void MenuScenecxx . . $ MenuScene(49f6e7a06ebc5aa8).(); // display menu scene |
| 107 | ///////////////////////////////////////////////////////////////////// |
| 108 | // gcc doesn't like the tQueue template in psclass.h |
| 109 | #if defined(POSIXcxx . . $ `<built-in>:480:9`!) |
| 110 | // tQueue |
| 111 | // a circular queue implementation |
| 112 | class tmmItemQueuecxx . . $ tmmItemQueue# { |
| 113 | #define tmmItemSIZEcxx . . $ `Descent3/mmItem.h:113:9`! 8 |
| 114 | tmmItemFXcxx . . $ tmmItemFX# m_itemscxx . . $ tmmItemQueue#m_items.[tmmItemSIZEcxx . . $ `Descent3/mmItem.h:113:9`!]; |
| 115 | int16_t m_headcxx . . $ tmmItemQueue#m_head., m_tailcxx . . $ tmmItemQueue#m_tail.; |
| 116 | |
| 117 | public: |
| 118 | tmmItemQueuecxx . . $ tmmItemQueue#tmmItemQueue(49f6e7a06ebc5aa8).() { m_headcxx . . $ tmmItemQueue#m_head. = m_tailcxx . . $ tmmItemQueue#m_tail. = 0; }; |
| 119 | ~cxx . . $ tmmItemQueue#`~tmmItemQueue`(ced63f7c635d850d).tmmItemQueuecxx . . $ tmmItemQueue#(){}; |
| 120 | void sendcxx . . $ tmmItemQueue#send(b6058802d21cb2be).(tmmItemFXcxx . . $ tmmItemFX# &item) { // sends an item onto the queue |
| 121 | int16_t temp = m_tailcxx . . $ tmmItemQueue#m_tail. + 1; |
| 122 | if (temp == tmmItemSIZEcxx . . $ `Descent3/mmItem.h:113:9`!) |
| 123 | temp = 0; |
| 124 | if (temp != m_headcxx . . $ tmmItemQueue#m_head.) { |
| 125 | m_itemscxx . . $ tmmItemQueue#m_items.[m_tailcxx . . $ tmmItemQueue#m_tail.] = item; |
| 126 | m_tailcxx . . $ tmmItemQueue#m_tail. = temp; |
| 127 | } |
| 128 | }; |
| 129 | bool recvcxx . . $ tmmItemQueue#recv(7c630a96e4db74eb).(tmmItemFXcxx . . $ tmmItemFX# *item) { // returns an item from the queue, false if no item. |
| 130 | if (m_headcxx . . $ tmmItemQueue#m_head. == m_tailcxx . . $ tmmItemQueue#m_tail.) |
| 131 | return false; |
| 132 | *item = m_itemscxx . . $ tmmItemQueue#m_items.[m_headcxx . . $ tmmItemQueue#m_head.++]; |
| 133 | if (m_headcxx . . $ tmmItemQueue#m_head. == tmmItemSIZEcxx . . $ `Descent3/mmItem.h:113:9`!) |
| 134 | m_headcxx . . $ tmmItemQueue#m_head. = 0; |
| 135 | return true; |
| 136 | }; |
| 137 | void flushcxx . . $ tmmItemQueue#flush(49f6e7a06ebc5aa8).() { // flush queue entries. |
| 138 | m_headcxx . . $ tmmItemQueue#m_head. = m_tailcxx . . $ tmmItemQueue#m_tail. = 0; |
| 139 | }; |
| 140 | }; |
| 141 | #endif |
| 142 | ////////////////////////////////////////////////////////////////////// |
| 143 | class mmInterfacecxx . . $ mmInterface#; |
| 144 | // class mmItem |
| 145 | class mmItemcxx . . $ mmItem# : public UIGadgetcxx . . $ UIGadget# { |
| 146 | char *m_textcxx . . $ mmItem#m_text.; // text for item |
| 147 | int16_t m_alphacxx . . $ mmItem#m_alpha.; // alpha for text item |
| 148 | int16_t m_satcountcxx . . $ mmItem#m_satcount.; |
| 149 | tmmItemFXcxx . . $ tmmItemFX# m_curfxcxx . . $ mmItem#m_curfx.; // current effect |
| 150 | #if !defined(POSIXcxx . . $ `<built-in>:480:9`!) |
| 151 | tQueue<tmmItemFX, 8> m_fxqueue; // special effects queue |
| 152 | #else |
| 153 | tmmItemQueuecxx . . $ tmmItemQueue# m_fxqueuecxx . . $ mmItem#m_fxqueue.; |
| 154 | #endif |
| 155 | ddgr_colorcxx . . $ ddgr_color# m_colorscxx . . $ mmItem#m_colors.[6]; // colors for menu (4 corners and 2 mid points) |
| 156 | float m_process_speedcxx . . $ mmItem#m_process_speed.; // speed gadget is processed (state changes, etc every x seconds) |
| 157 | float m_last_frametimecxx . . $ mmItem#m_last_frametime.; // last frame's time. |
| 158 | static mmInterfacecxx . . $ mmInterface# *m_windowcxx . . $ mmItem#m_window.; // attached window |
| 159 | public: |
| 160 | mmItemcxx . . $ mmItem#mmItem(49f6e7a06ebc5aa8).(); |
| 161 | virtual ~cxx . . $ mmItem#`~mmItem`(ced63f7c635d850d).mmItemcxx . . $ mmItem#(); |
| 162 | |
| 163 | public: |
| 164 | // attaches a window to all mmitems. |
| 165 | static void AttachInterfacecxx . . $ mmItem#AttachInterface(b617a8135d67409).(mmInterfacecxx . . $ mmInterface# *wnd); |
| 166 | void Createcxx . . $ mmItem#Create(c9e50ccfae272660).(int id, int key, int x, int y, const char *text, int flags, tmmItemFXcxx . . $ tmmItemFX# init_fx = mmItemFXNormalcxx . . $ mmItemFXNormal.); |
| 167 | void AddEffectcxx . . $ mmItem#AddEffect(9a2e9a6d763c3e3f).(tmmItemFXcxx . . $ tmmItemFX# fx); |
| 168 | void ClearEffectscxx . . $ mmItem#ClearEffects(49f6e7a06ebc5aa8).(); |
| 169 | |
| 170 | protected: |
| 171 | virtual void OnMouseBtnDowncxx . . $ mmItem#OnMouseBtnDown(d4f767463ce0a6b3).(int btn); // override: behavior when mouse button is pressed. |
| 172 | virtual void OnMouseBtnUpcxx . . $ mmItem#OnMouseBtnUp(d4f767463ce0a6b3).(int btn); // override: behavior when mouse button is released. |
| 173 | virtual void OnFormatcxx . . $ mmItem#OnFormat(49f6e7a06ebc5aa8).(); // override: called when resized or before drawing. |
| 174 | virtual void OnDrawcxx . . $ mmItem#OnDraw(49f6e7a06ebc5aa8).(); // override: behavior when gadget is being drawn. |
| 175 | virtual void OnLostFocuscxx . . $ mmItem#OnLostFocus(49f6e7a06ebc5aa8).(); // override: behavior when gadget loses input focus. |
| 176 | virtual void OnGainFocuscxx . . $ mmItem#OnGainFocus(49f6e7a06ebc5aa8).(); // override: behavior when gadget gains input focus. |
| 177 | virtual void OnDestroycxx . . $ mmItem#OnDestroy(49f6e7a06ebc5aa8).(); // override: behavior when gadget is destroyed. |
| 178 | virtual void OnUserProcesscxx . . $ mmItem#OnUserProcess(49f6e7a06ebc5aa8).(); // override: behavior when gadget is processed |
| 179 | virtual void OnSelectcxx . . $ mmItem#OnSelect(49f6e7a06ebc5aa8).(); |
| 180 | }; |
| 181 | // Main Menu Interface Object |
| 182 | |
| 183 | class mmInterfacecxx . . $ mmInterface# : public UIWindowcxx . . $ UIWindow# { |
| 184 | int m_nmenu_itemscxx . . $ mmInterface#m_nmenu_items.; // number of menu items available. |
| 185 | mmItemcxx . . $ mmItem# m_menuitemscxx . . $ mmInterface#m_menuitems.[N_MMENU_ITEMScxx . . $ `Descent3/mmItem.h:86:9`!]; // main menu items |
| 186 | #ifdef MOVIE_MENUcxx . . $ `Descent3/mmItem.h:78:9`! |
| 187 | tCinematiccxx . . $ tCinematic# *m_moviecxx . . $ mmInterface#m_movie.; // menu movie handle |
| 188 | #endif |
| 189 | tLargeBitmapcxx . . $ tLargeBitmap# m_artcxx . . $ mmInterface#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 AddItemcxx . . $ mmInterface#AddItem(f6af4ec68985d813).(int id, int key, const char *text, int type = 0); |
| 193 | void Createcxx . . $ mmInterface#Create(49f6e7a06ebc5aa8).(); |
| 194 | int DoUIcxx . . $ mmInterface#DoUI(b126dc7c1de90089).(); // does user interface. |
| 195 | public: |
| 196 | int SoundHandlescxx . . $ mmInterface#SoundHandles.[N_MM_SOUNDScxx . . $ `Descent3/mmItem.h:90:9`!]; |
| 197 | void SetMusicRegioncxx . . $ mmInterface#SetMusicRegion(d4f767463ce0a6b3).(int region); |
| 198 | friend void MenuScenecxx . . $ MenuScene(49f6e7a06ebc5aa8).(); // display menu scene |
| 199 | protected: |
| 200 | virtual void OnDestroycxx . . $ mmInterface#OnDestroy(49f6e7a06ebc5aa8).(); // destroys window. |
| 201 | private: |
| 202 | void CopyrightTextcxx . . $ mmInterface#CopyrightText(49f6e7a06ebc5aa8).(); // displays the copyright text |
| 203 | }; |
| 204 | #endif |