OpenMoHAA 0.82.0
Loading...
Searching...
No Matches
bg_voteoptions.h
1/*
2===========================================================================
3Copyright (C) 2023 the OpenMoHAA team
4
5This file is part of OpenMoHAA source code.
6
7OpenMoHAA source code is free software; you can redistribute it
8and/or modify it under the terms of the GNU General Public License as
9published by the Free Software Foundation; either version 2 of the License,
10or (at your option) any later version.
11
12OpenMoHAA source code is distributed in the hope that it will be
13useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with OpenMoHAA source code; if not, write to the Free Software
19Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20===========================================================================
21*/
22
23#pragma once
24
25#ifdef __cplusplus
26# include "listener.h"
27#endif
28
29#include "g_public.h"
30
31#ifdef __cplusplus
32
33static const unsigned long MAX_VOTEOPTIONS_UPLOAD_BUFFER_LENGTH = 2024;
34static const unsigned long MAX_VOTEOPTIONS_BUFFER_LENGTH = 0x100000;
35
36typedef enum voteoptiontype_e {
38 VOTE_NO_CHOICES,
40 VOTE_OPTION_LIST,
42 VOTE_OPTION_TEXT,
44 VOTE_OPTION_INTEGER,
46 VOTE_OPTION_FLOAT,
48 VOTE_OPTION_CLIENT,
50 VOTE_OPTION_CLIENT_NOT_SELF,
51} voteoptiontype_t;
52
53class VoteOptionListItem
54{
55public:
56 str m_sItemName;
57 str m_sCommand;
58 class VoteOptionListItem *m_pNext;
59
60public:
61 VoteOptionListItem();
62};
63
64class SingleVoteOption
65{
66public:
67 str m_sOptionName;
68 str m_sCommand;
69 voteoptiontype_t m_optionType;
70 VoteOptionListItem *m_pListItem;
71 SingleVoteOption *m_pNext;
72
73public:
74 SingleVoteOption();
75 ~SingleVoteOption();
76};
77
78class VoteOptions : public Class
79{
80public:
81 CLASS_PROTOTYPE(VoteOptions);
82
83private:
84 str m_sFileName;
85 str m_sBuffer;
86 SingleVoteOption *m_pHeadOption;
87
88public:
89 VoteOptions();
90 ~VoteOptions();
91
92 bool IsSetup() const;
93
94 void ClearOptions();
95 void SetupVoteOptions(const char *configFileName);
96 void SetupVoteOptions(const char *configFileName, int length, const char *buffer);
97 void ParseVoteOptions();
98 const char *GetVoteOptionsFile(int *outLen) const;
99 bool GetVoteOptionsMain(int index, str *outOptionCommand, voteoptiontype_t *outOptionType) const;
100 bool GetVoteOptionSub(int index, int listIndex, str *outCommand) const;
101 bool GetVoteOptionMainName(int index, str *outVoteName) const;
102 bool GetVoteOptionSubName(int index, int listIndex, str *outName) const;
103
104 void SetupMainOptionsList();
105 void SetupSubOptionsList(int index);
106};
107
108inline bool VoteOptions::IsSetup() const
109{
110 return m_pHeadOption != NULL;
111}
112
113#endif
114
115#ifdef __cplusplus
116extern "C" {
117#endif
118
119#if defined(CGAME_DLL)
120 void CG_VoteOptions_StartReadFromServer(const char *string);
121 void CG_VoteOptions_ContinueReadFromServer(const char *string);
122 void CG_VoteOptions_FinishReadFromServer(const char *string);
123 void CG_PushCallVote_f(void);
124 void CG_PushCallVoteSubList_f(void);
125 void CG_PushCallVoteSubText_f(void);
126 void CG_PushCallVoteSubInteger_f(void);
127 void CG_PushCallVoteSubFloat_f(void);
128 void CG_PushCallVoteSubClient_f(void);
129 void CG_PushVote_f(void);
130 void CG_CallEntryVote_f(void);
131#endif
132
133#ifdef __cplusplus
134}
135#endif
Definition class.h:276