Skip to content

Commit beadcf6

Browse files
committed
Unify enums
1 parent af066f0 commit beadcf6

29 files changed

Lines changed: 287 additions & 205 deletions

src/ui/GameEnums.h

Lines changed: 55 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,64 @@ inline QStringList weaponAnimations() {
6060
}
6161

6262
/**
63-
* @brief Ammo caliber types
63+
* @brief Ammo caliber types (19 types from proto.msg)
64+
* FIXME: read directly from proto.msg?
6465
*/
6566
inline QStringList ammoCaliberTypes() {
66-
return { "None", ".223", ".44 Magnum", "Flamethrower Fuel",
67-
"14mm", "2mm EC", "4.7mm Caseless", "9mm",
68-
"7.62mm", "Batteries", "Micro Fusion Cell",
69-
"Rocket", "Shotgun Shells", "Small Energy Cell", "HN Needler" };
67+
return { "None", ".223 FMJ", "5mm JHP", "5mm AP", "10mm JHP", "10mm AP",
68+
".44 Magnum JHP", ".44 Magnum FMJ", "14mm AP", "12 ga. Shotgun",
69+
"7.62mm", "9mm", "BB's", "Energy Cell", "Micro Fusion Cell",
70+
"Small Energy Cell", "Flamethrower Fuel", "Rocket", "Plasma" };
7071
}
7172

72-
// Constants for array sizing
73-
constexpr int DAMAGE_TYPES_BASIC = 7;
74-
constexpr int DAMAGE_TYPES_EXTENDED = 9;
75-
constexpr int MATERIAL_TYPES = 8;
76-
constexpr int ORIENTATIONS = 6;
77-
constexpr int ELEVATIONS = 3;
73+
/**
74+
* @brief Weapon perks
75+
*/
76+
inline QStringList weaponPerks() {
77+
return { "None", "Fast Shot", "Long Range", "Accurate", "Penetrate",
78+
"Knockback", "Knockdown", "Flame", "Other" };
79+
}
80+
81+
/**
82+
* @brief Armor perks
83+
*/
84+
inline QStringList armorPerks() {
85+
return { "None", "PowerArmor", "CombatArmor", "Other" };
86+
}
87+
88+
/**
89+
* @brief Container action flags
90+
*/
91+
inline QStringList containerFlags() {
92+
return { "Use", "Use On", "Look", "Talk", "Pickup" };
93+
}
94+
95+
/**
96+
* @brief Critter genders
97+
*/
98+
inline QStringList critterGenders() {
99+
return { "Male", "Female" };
100+
}
101+
102+
/**
103+
* @brief Critter body types
104+
*/
105+
inline QStringList critterBodyTypes() {
106+
return { "Biped", "Quadruped", "Robotic" };
107+
}
108+
109+
/**
110+
* @brief Scenery subtypes
111+
*/
112+
inline QStringList sceneryTypes() {
113+
return { "Door", "Stairs", "Elevator", "Ladder Bottom", "Ladder Top", "Generic" };
114+
}
115+
116+
/**
117+
* @brief Text file extensions (for syntax highlighting)
118+
*/
119+
inline QStringList textFileExtensions() {
120+
return { "cfg", "txt", "gam", "msg", "lst", "int", "ssl", "ini" };
121+
}
78122

79123
} // namespace geck::game::enums

src/ui/UIConstants.h

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ namespace ui {
4141
// Button sizes
4242
constexpr int ICON_BUTTON = 24;
4343
constexpr int ICON_BUTTON_SMALL = 20;
44+
constexpr int ICON_BUTTON_HEIGHT = 22; // Height for small icon buttons
45+
constexpr int NAV_BUTTON = 30; // Navigation/pagination buttons
4446

4547
// Field sizes
4648
constexpr int SPINBOX_COMPACT = 40;
@@ -49,13 +51,33 @@ namespace ui {
4951
// Label sizes
5052
constexpr int LABEL_MIN_WIDTH = 40;
5153
constexpr int LABEL_STANDARD = 80;
54+
constexpr int LABEL_FRAME = 30; // Frame number labels
55+
constexpr int LABEL_FRAME_WIDE = 40; // Wider frame labels
5256

5357
// Preview sizes
5458
constexpr int PREVIEW_SMALL = 80;
55-
constexpr int PREVIEW_MEDIUM = 120;
56-
constexpr int PREVIEW_LARGE = 200;
59+
constexpr int PREVIEW_TILE = 120; // Tile/item previews
60+
constexpr int PREVIEW_TILE_HEIGHT = 96; // Tile preview height
61+
constexpr int PREVIEW_MEDIUM = 128; // Object previews
62+
constexpr int PREVIEW_LARGE = 200; // FRM selector preview
63+
64+
// Panel sizes
65+
constexpr int PANEL_MIN_HEIGHT = 300; // Minimum panel height
5766
}
5867

68+
// Group box margins
69+
constexpr int GROUP_MARGIN = 8; // Standard horizontal margin
70+
constexpr int GROUP_MARGIN_VERTICAL = 12; // Vertical margin with title padding
71+
constexpr int COMPACT_MARGIN = 4; // Compact grid/palette layouts
72+
constexpr int DIALOG_PADDING = 20; // Main dialog content padding
73+
constexpr int PANEL_CONTENT_MARGIN = 5; // Panel content padding
74+
75+
// Animation timing
76+
constexpr int ANIMATION_TIMER_INTERVAL = 200; // Animation frame interval (ms)
77+
78+
// Layout spacing
79+
constexpr int SPACING_WIDE = 10; // Wide spacing for major sections
80+
5981
// Dialog sizes
6082
constexpr int SETTINGS_MIN_WIDTH = 780;
6183
constexpr int SETTINGS_MIN_HEIGHT = 620;

src/ui/core/MainWindow.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "../../writer/map/MapWriter.h"
3030
#include "../../editor/Object.h"
3131
#include "../IconHelper.h"
32+
#include "../GameEnums.h"
3233

3334
#include "../../vfs/VfsppNativeFileSystem.h"
3435

@@ -1890,11 +1891,8 @@ void MainWindow::onPlayGame() {
18901891
}
18911892

18921893
bool MainWindow::isTextFile(const QString& filePath) const {
1893-
static const QStringList textExtensions = {
1894-
"cfg", "txt", "gam", "msg", "lst", "int", "ssl", "ini"
1895-
};
18961894
QString suffix = QFileInfo(filePath).suffix().toLower();
1897-
return textExtensions.contains(suffix);
1895+
return game::enums::textFileExtensions().contains(suffix);
18981896
}
18991897

19001898
void MainWindow::openTextFileWithEditor(const QString& vfsFilePath) {

src/ui/dialogs/AboutDialog.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "version.h"
99
#include "../../Application.h"
1010
#include "../theme/ThemeManager.h"
11+
#include "../UIConstants.h"
1112

1213
namespace geck {
1314

@@ -30,7 +31,8 @@ void AboutDialog::setupUI() {
3031
setFixedSize(400, 200);
3132

3233
_mainLayout = new QVBoxLayout(this);
33-
_mainLayout->setContentsMargins(20, 20, 20, 20);
34+
_mainLayout->setContentsMargins(ui::constants::DIALOG_PADDING, ui::constants::DIALOG_PADDING,
35+
ui::constants::DIALOG_PADDING, ui::constants::DIALOG_PADDING);
3436
_mainLayout->setSpacing(15);
3537

3638
createContent();

src/ui/dialogs/FrmSelectorDialog.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "FrmSelectorDialog.h"
22
#include "../theme/ThemeManager.h"
3+
#include "../UIConstants.h"
34

45
#include <QApplication>
56
#include <QPixmap>
@@ -78,8 +79,8 @@ void FrmSelectorDialog::setupUI() {
7879

7980
_previewLabel = new QLabel("No FRM selected");
8081
_previewLabel->setAlignment(Qt::AlignCenter);
81-
_previewLabel->setMinimumHeight(200);
82-
_previewLabel->setMinimumWidth(200);
82+
_previewLabel->setMinimumHeight(ui::constants::sizes::PREVIEW_LARGE);
83+
_previewLabel->setMinimumWidth(ui::constants::sizes::PREVIEW_LARGE);
8384
_previewLabel->setScaledContents(false);
8485
_previewLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
8586
_previewLabel->setStyleSheet(ui::theme::styles::previewArea());

src/ui/dialogs/InventoryViewerDialog.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "../../format/pro/Pro.h"
77
#include "../../format/msg/Msg.h"
88
#include "../theme/ThemeManager.h"
9+
#include "../UIConstants.h"
910

1011
#include <QApplication>
1112
#include <QHeaderView>
@@ -129,14 +130,14 @@ void InventoryViewerDialog::setupUI() {
129130
// Preview group
130131
_previewGroup = new QGroupBox("Item Preview");
131132
_previewFormLayout = new QFormLayout(_previewGroup);
132-
_previewFormLayout->setContentsMargins(8, 12, 8, 8);
133+
_previewFormLayout->setContentsMargins(ui::constants::GROUP_MARGIN, ui::constants::GROUP_MARGIN_VERTICAL, ui::constants::GROUP_MARGIN, ui::constants::GROUP_MARGIN);
133134
_previewFormLayout->setSpacing(6);
134135

135136
// Item sprite preview
136137
_previewLabel = new QLabel("No item selected");
137138
_previewLabel->setAlignment(Qt::AlignCenter);
138-
_previewLabel->setMinimumSize(120, 120);
139-
_previewLabel->setMaximumSize(120, 120);
139+
_previewLabel->setMinimumSize(ui::constants::sizes::PREVIEW_TILE, ui::constants::sizes::PREVIEW_TILE);
140+
_previewLabel->setMaximumSize(ui::constants::sizes::PREVIEW_TILE, ui::constants::sizes::PREVIEW_TILE);
140141
_previewLabel->setScaledContents(false);
141142
_previewLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
142143
_previewLabel->setStyleSheet(ui::theme::styles::previewArea());

src/ui/dialogs/MessageSelectorDialog.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "MessageSelectorDialog.h"
22
#include "../../format/msg/Msg.h"
3+
#include "../theme/ThemeManager.h"
34

45
#include <QListWidget>
56
#include <QPushButton>
@@ -43,7 +44,7 @@ void MessageSelectorDialog::setupUI() {
4344

4445
// Title label
4546
_titleLabel = new QLabel("Select a message from the list:");
46-
_titleLabel->setStyleSheet("QLabel { font-weight: bold; margin-bottom: 4px; }");
47+
_titleLabel->setStyleSheet(ui::theme::styles::boldLabelWithMargin());
4748
_mainLayout->addWidget(_titleLabel);
4849

4950
// Message list

0 commit comments

Comments
 (0)