| 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 | * $Logfile: /DescentIII/Main/CtlCfgElem.h $ |
| 21 | * $Revision: 15 $ |
| 22 | * $Date: 7/16/99 11:15a $ |
| 23 | * $Author: Samir $ |
| 24 | * |
| 25 | * Header file |
| 26 | * |
| 27 | * $Log: /DescentIII/Main/CtlCfgElem.h $ |
| 28 | * |
| 29 | * 15 7/16/99 11:15a Samir |
| 30 | * multiple hat support |
| 31 | * |
| 32 | * 14 4/14/99 3:56a Jeff |
| 33 | * fixed case mismatch in #includes |
| 34 | * |
| 35 | * 13 2/26/99 2:09a Samir |
| 36 | * added '?' button. |
| 37 | * |
| 38 | * 12 2/21/99 6:36p Samir |
| 39 | * focusing changes and key input changes to ui., |
| 40 | * |
| 41 | * 11 2/16/99 12:07p Samir |
| 42 | * redid controller config with new ui. |
| 43 | * |
| 44 | * 10 11/30/98 4:54p Samir |
| 45 | * added rear view config item. |
| 46 | * |
| 47 | * 9 10/22/98 4:11p Samir |
| 48 | * put inventory keys back in. |
| 49 | * |
| 50 | * 8 10/22/98 2:40p Samir |
| 51 | * took out inventory keys for demo. |
| 52 | * |
| 53 | * 7 10/21/98 12:32p Samir |
| 54 | * fixed problem with size of gadget. |
| 55 | * |
| 56 | * 6 10/18/98 1:07p Samir |
| 57 | * tweaked user interface for controller config. |
| 58 | * |
| 59 | * 5 10/17/98 7:31p Samir |
| 60 | * added invertible axes |
| 61 | * |
| 62 | * 4 10/08/98 10:52a Samir |
| 63 | * added countermeasure and weapon cycling. |
| 64 | * |
| 65 | * 3 10/02/98 4:15p Samir |
| 66 | * added fancy artwork for config screens. |
| 67 | * |
| 68 | * 2 9/30/98 4:37p Samir |
| 69 | * 'incremental checkin' |
| 70 | * |
| 71 | * 1 9/28/98 3:48p Samir |
| 72 | * initial revision |
| 73 | * |
| 74 | * $NoKeywords: $ |
| 75 | */ |
| 76 | |
| 77 | #ifndef CTLCFGELEM_H |
| 78 | #define CTLCFGELEM_Hcxx . . $ `Descent3/CtlCfgElem.h:78:9`! |
| 79 | |
| 80 | #include "newui.h"cxx . . $ `<file>/Descent3/newui.h`/ |
| 81 | #include "Controller.h"cxx . . $ `<file>/lib/Controller.h`/ |
| 82 | #include "controls.h"cxx . . $ `<file>/Descent3/controls.h`/ |
| 83 | #include "stringtable.h"cxx . . $ `<file>/Descent3/stringtable.h`/ |
| 84 | |
| 85 | ////////////////////////////////////////////////////////////////////////////// |
| 86 | // Data types |
| 87 | #define N_CFGELEM_SLOTScxx . . $ `Descent3/CtlCfgElem.h:87:9`! CTLBINDS_PER_FUNCcxx . . $ `lib/Controller.h:200:9`! // number of controller slots per function |
| 88 | #define CFGELEM_SLOT_CLEARcxx . . $ `Descent3/CtlCfgElem.h:88:9`! 2 |
| 89 | |
| 90 | ////////////////////////////////////////////////////////////////////////////// |
| 91 | // |
| 92 | class cfg_elementcxx . . $ cfg_element# : public UIGadgetcxx . . $ UIGadget# { |
| 93 | static UIBitmapItemcxx . . $ UIBitmapItem# *m_btn_bmp_litcxx . . $ cfg_element#m_btn_bmp_lit., *m_btn_bmpcxx . . $ cfg_element#m_btn_bmp., *m_xbtn_bmp_litcxx . . $ cfg_element#m_xbtn_bmp_lit., *m_xbtn_bmpcxx . . $ cfg_element#m_xbtn_bmp.; |
| 94 | static int16_tcxx . . $ int16_t# m_countcxx . . $ cfg_element#m_count.; |
| 95 | const char *m_titlecxx . . $ cfg_element#m_title.; |
| 96 | int8_tcxx . . $ int8_t# m_fnidcxx . . $ cfg_element#m_fnid., m_flagscxx . . $ cfg_element#m_flags.; // fnflags : 1 if invert btn visible |
| 97 | int8_tcxx . . $ int8_t# m_slotcxx . . $ cfg_element#m_slot., m_curslotcxx . . $ cfg_element#m_curslot.; // what slow is in focus and number of slots. |
| 98 | uint8_tcxx . . $ uint8_t# m_slot_alphacxx . . $ cfg_element#m_slot_alpha.; |
| 99 | int8_tcxx . . $ int8_t# m_blink_statecxx . . $ cfg_element#m_blink_state.; |
| 100 | |
| 101 | public: |
| 102 | void Createcxx . . $ cfg_element#Create(d616eeffcc609617).(UIWindowcxx . . $ UIWindow# *wnd, int str_i, int x, int y, int fnid, int id); |
| 103 | int8_tcxx . . $ int8_t# GetActiveSlotcxx . . $ cfg_element#GetActiveSlot(4f2304c4a29b870b).() const { return m_slotcxx . . $ cfg_element#m_slot.; }; |
| 104 | bool Configurecxx . . $ cfg_element#Configure(ccaa17bdaf66462f).(ct_typecxx . . $ ct_type# *elem_type, uint8_tcxx . . $ uint8_t# *controller, uint8_tcxx . . $ uint8_t# *new_elem, |
| 105 | int8_tcxx . . $ int8_t# *slot); // calls configuration routines (returns true if approved) |
| 106 | |
| 107 | protected: |
| 108 | virtual void OnDrawcxx . . $ cfg_element#OnDraw(49f6e7a06ebc5aa8).(); |
| 109 | virtual void OnKeyDowncxx . . $ cfg_element#OnKeyDown(d4f767463ce0a6b3).(int key); |
| 110 | virtual void OnMouseBtnDowncxx . . $ cfg_element#OnMouseBtnDown(d4f767463ce0a6b3).(int btn); |
| 111 | virtual void OnMouseBtnUpcxx . . $ cfg_element#OnMouseBtnUp(d4f767463ce0a6b3).(int btn); |
| 112 | virtual void OnLostFocuscxx . . $ cfg_element#OnLostFocus(49f6e7a06ebc5aa8).(); |
| 113 | virtual void OnGainFocuscxx . . $ cfg_element#OnGainFocus(49f6e7a06ebc5aa8).(); |
| 114 | virtual void OnDestroycxx . . $ cfg_element#OnDestroy(49f6e7a06ebc5aa8).(); |
| 115 | virtual void OnFormatcxx . . $ cfg_element#OnFormat(49f6e7a06ebc5aa8).(); |
| 116 | }; |
| 117 | |
| 118 | struct tCfgDataPartscxx . . $ tCfgDataParts# { |
| 119 | uint8_tcxx . . $ uint8_t# bind_0cxx . . $ tCfgDataParts#bind_0., bind_1cxx . . $ tCfgDataParts#bind_1., ctrl_0cxx . . $ tCfgDataParts#ctrl_0., ctrl_1cxx . . $ tCfgDataParts#ctrl_1.; |
| 120 | }; |
| 121 | |
| 122 | static inline void parse_config_datacxx . . $ parse_config_data(7e428e3458f6a03b).(tCfgDataPartscxx . . $ tCfgDataParts# *parts, ct_typecxx . . $ ct_type# type0, ct_typecxx . . $ ct_type# type1, ct_config_datacxx . . $ ct_config_data# cfgdata) { |
| 123 | switch (type0) { |
| 124 | case ctKeycxx . . $ ctKey.: |
| 125 | parts->bind_0cxx . . $ tCfgDataParts#bind_0. = CONTROLLER_KEY1_VALUEcxx . . $ `lib/Controller.h:184:9`!(CONTROLLER_VALUEcxx . . $ `lib/Controller.h:196:9`!(cfgdata)); |
| 126 | break; |
| 127 | case ctAxiscxx . . $ ctAxis.: |
| 128 | case ctMouseAxiscxx . . $ ctMouseAxis.: |
| 129 | case ctButtoncxx . . $ ctButton.: |
| 130 | case ctMouseButtoncxx . . $ ctMouseButton.: |
| 131 | case ctPOVcxx . . $ ctPOV.: |
| 132 | case ctPOV2cxx . . $ ctPOV2.: |
| 133 | case ctPOV3cxx . . $ ctPOV3.: |
| 134 | case ctPOV4cxx . . $ ctPOV4.: |
| 135 | parts->bind_0cxx . . $ tCfgDataParts#bind_0. = CONTROLLER_CTL1_VALUEcxx . . $ uint16_t#(CONTROLLER_VALUEcxx . . $ `lib/Controller.h:196:9`!(cfgdata)); |
| 136 | break; |
| 137 | default: |
| 138 | parts->bind_0cxx . . $ tCfgDataParts#bind_0. = 0; |
| 139 | } |
| 140 | |
| 141 | switch (type1) { |
| 142 | case ctKeycxx . . $ ctKey.: |
| 143 | parts->bind_1cxx . . $ tCfgDataParts#bind_1. = CONTROLLER_KEY2_VALUEcxx . . $ `lib/Controller.h:185:9`!(CONTROLLER_VALUEcxx . . $ `lib/Controller.h:196:9`!(cfgdata)); |
| 144 | break; |
| 145 | case ctAxiscxx . . $ ctAxis.: |
| 146 | case ctMouseAxiscxx . . $ ctMouseAxis.: |
| 147 | case ctButtoncxx . . $ ctButton.: |
| 148 | case ctMouseButtoncxx . . $ ctMouseButton.: |
| 149 | case ctPOVcxx . . $ ctPOV.: |
| 150 | case ctPOV2cxx . . $ ctPOV2.: |
| 151 | case ctPOV3cxx . . $ ctPOV3.: |
| 152 | case ctPOV4cxx . . $ ctPOV4.: |
| 153 | parts->bind_1cxx . . $ tCfgDataParts#bind_1. = CONTROLLER_CTL2_VALUEcxx . . $ `lib/Controller.h:189:9`!(CONTROLLER_VALUEcxx . . $ `lib/Controller.h:196:9`!(cfgdata)); |
| 154 | break; |
| 155 | default: |
| 156 | parts->bind_1cxx . . $ tCfgDataParts#bind_1. = 0; |
| 157 | } |
| 158 | |
| 159 | parts->ctrl_0cxx . . $ tCfgDataParts#ctrl_0. = CONTROLLER_CTL1_INFOcxx . . $ int16_t#(CONTROLLER_INFOcxx . . $ `lib/Controller.h:197:9`!(cfgdata)); |
| 160 | parts->ctrl_1cxx . . $ tCfgDataParts#ctrl_1. = CONTROLLER_CTL2_INFOcxx . . $ `lib/Controller.h:193:9`!(CONTROLLER_INFOcxx . . $ `lib/Controller.h:197:9`!(cfgdata)); |
| 161 | } |
| 162 | |
| 163 | static inline ct_config_datacxx . . $ ct_config_data# unify_config_datacxx . . $ unify_config_data(93c052a99c9f35a1).(tCfgDataPartscxx . . $ tCfgDataParts# *parts) { |
| 164 | return MAKE_CONFIG_DATAcxx . . $ tCfgDataParts#ctrl_1.(CONTROLLER_CTL_INFOcxx . . $ `lib/Controller.h:194:9`!(parts->ctrl_0, parts->ctrl_1), |
| 165 | CONTROLLER_CTL_VALUEcxx . . $ `lib/Controller.h:190:9`!(parts->bind_0, parts->bind_1)); |
| 166 | } |
| 167 | |
| 168 | extern const char *cfg_binding_textcxx . . $ cfg_binding_text(c156078267dcf458).(ct_typecxx . . $ ct_type# ctype, uint8_tcxx . . $ uint8_t# ctrl, uint8_tcxx . . $ uint8_t# binding); |
| 169 | |
| 170 | #endif |