OpenMoHAA ..
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 "../corepp/listener.h"
27#endif
28
29#include "g_public.h"
30
31#ifdef __cplusplus
32
33static const unsigned long MAX_VOTEOPTIONS_BUFFER_LENGTH = 0x100000;
34static const unsigned long MAX_VOTEOPTIONS_UPLOAD_BUFFER_LENGTH = 2024;
35static const unsigned long MAX_VOTEOPTIONS_UPLOAD_BURST = 5;
36
37typedef enum voteoptiontype_e {
39 VOTE_NO_CHOICES,
41 VOTE_OPTION_LIST,
43 VOTE_OPTION_TEXT,
45 VOTE_OPTION_INTEGER,
47 VOTE_OPTION_FLOAT,
49 VOTE_OPTION_CLIENT,
51 VOTE_OPTION_CLIENT_NOT_SELF,
52} voteoptiontype_t;
53
54class VoteOptionListItem
55{
56public:
57 str m_sItemName;
58 str m_sCommand;
59 class VoteOptionListItem *m_pNext;
60
61public:
62 VoteOptionListItem();
63};
64
65class SingleVoteOption
66{
67public:
68 str m_sOptionName;
69 str m_sCommand;
70 voteoptiontype_t m_optionType;
71 VoteOptionListItem *m_pListItem;
72 SingleVoteOption *m_pNext;
73
74public:
75 SingleVoteOption();
76 ~SingleVoteOption();
77};
78
79class VoteOptions : public Class
80{
81public:
82 CLASS_PROTOTYPE(VoteOptions);
83
84private:
85 str m_sFileName;
86 str m_sBuffer;
87 SingleVoteOption *m_pHeadOption;
88
89public:
90 VoteOptions();
91 ~VoteOptions();
92
93 bool IsSetup() const;
94
95 void ClearOptions();
96 void SetupVoteOptions(const char *configFileName);
97 void SetupVoteOptions(const char *configFileName, int length, const char *buffer);
98 void ParseVoteOptions();
99 const char *GetVoteOptionsFile(int *outLen) const;
100 bool GetVoteOptionsMain(int index, str *outOptionCommand, voteoptiontype_t *outOptionType) const;
101 bool GetVoteOptionSub(int index, int listIndex, str *outCommand) const;
102 bool GetVoteOptionMainName(int index, str *outVoteName) const;
103 bool GetVoteOptionSubName(int index, int listIndex, str *outName) const;
104
105 void SetupMainOptionsList();
106 void SetupSubOptionsList(int index);
107};
108
109inline bool VoteOptions::IsSetup() const
110{
111 return m_pHeadOption != NULL;
112}
113
114#endif
115
116#ifdef __cplusplus
117extern "C" {
118#endif
119
120#if defined(CGAME_DLL)
121 void CG_VoteOptions_StartReadFromServer(const char *string);
122 void CG_VoteOptions_ContinueReadFromServer(const char *string);
123 void CG_VoteOptions_FinishReadFromServer(const char *string);
124 void CG_PushCallVote_f(void);
125 void CG_PushCallVoteSubList_f(void);
126 void CG_PushCallVoteSubText_f(void);
127 void CG_PushCallVoteSubInteger_f(void);
128 void CG_PushCallVoteSubFloat_f(void);
129 void CG_PushCallVoteSubClient_f(void);
130 void CG_PushVote_f(void);
131 void CG_CallEntryVote_f(void);
132#endif
133
134#ifdef __cplusplus
135}
136#endif