Skip to content

Commit a223130

Browse files
committed
Merge branch 'working'
2 parents ed2626e + 5a8da01 commit a223130

292 files changed

Lines changed: 4176 additions & 3813 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.clang-format

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
Language: Cpp
2+
Standard: Latest
3+
4+
ColumnLimit: 80
5+
IndentWidth: 4
6+
LineEnding: LF
7+
UseTab: Never
8+
9+
AccessModifierOffset: -4
10+
11+
AlignAfterOpenBracket: AlwaysBreak
12+
AlignArrayOfStructures: Right
13+
AlignConsecutiveAssignments: None
14+
AlignConsecutiveDeclarations: None
15+
AlignEscapedNewlines: LeftWithLastLine
16+
AlignOperands: DontAlign
17+
18+
AllowAllArgumentsOnNextLine: false
19+
AllowAllParametersOfDeclarationOnNextLine: false
20+
21+
AllowShortBlocksOnASingleLine: Empty
22+
AllowShortFunctionsOnASingleLine: Inline
23+
AllowShortIfStatementsOnASingleLine: Never
24+
AllowShortLambdasOnASingleLine: All
25+
AllowShortLoopsOnASingleLine: false
26+
27+
BinPackArguments: false
28+
BinPackParameters: false
29+
# BinPackParameters: OnePerLine
30+
31+
BreakBeforeBinaryOperators: All
32+
BreakBeforeBraces: Allman
33+
BreakBeforeTernaryOperators: true
34+
BreakConstructorInitializers: BeforeComma
35+
BreakInheritanceList: BeforeComma
36+
BreakTemplateDeclarations: Yes
37+
38+
CompactNamespaces: false
39+
40+
ConstructorInitializerIndentWidth: 0
41+
42+
EmptyLineBeforeAccessModifier: Always
43+
44+
FixNamespaceComments: true
45+
46+
IndentAccessModifiers: false
47+
IndentCaseLabels: false
48+
IndentGotoLabels: false
49+
50+
InsertBraces: true # WARNING: May create incorrect code
51+
InsertNewlineAtEOF: true
52+
53+
LambdaBodyIndentation: Signature
54+
55+
NamespaceIndentation: All
56+
57+
PackConstructorInitializers: Never
58+
59+
PenaltyReturnTypeOnItsOwnLine: 1000
60+
61+
PointerAlignment: Right
62+
ReferenceAlignment: Right
63+
64+
QualifierAlignment: Custom # WARNING: May create invalid code
65+
QualifierOrder: [friend, static, inline, constexpr, volatile, type, restrict, const]
66+
67+
# RemoveEmptyLinesInUnwrappedLines: true
68+
69+
SeparateDefinitionBlocks: Always
70+
71+
SortIncludes: CaseInsensitive
72+
SortUsingDeclarations: Lexicographic
73+
74+
SpaceAfterCStyleCast: false
75+
SpaceAfterLogicalNot: false
76+
SpaceAfterTemplateKeyword: false
77+
SpaceAroundPointerQualifiers: Default
78+
SpaceBeforeAssignmentOperators: true
79+
SpaceBeforeCaseColon: false
80+
SpaceBeforeCpp11BracedList: false
81+
SpaceBeforeInheritanceColon: true
82+
SpaceBeforeParens: ControlStatementsExceptControlMacros
83+
SpaceBeforeRangeBasedForLoopColon: true
84+
SpaceBeforeSquareBrackets: false
85+
SpacesInAngles: false
86+
SpacesInParens: Never
87+
SpacesInSquareBrackets: false

.github/workflows/cmake-multi-platform.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,6 @@ jobs:
6565
sudo apt-get update
6666
sudo apt-get install bison flex libfl-dev libglew-dev libgtkmm-3.0-dev liblua5.4-dev
6767
68-
- name: Workaround for flex bug.
69-
# See https://github.com/msys2/MSYS2-packages/issues/1911#issuecomment-832199076
70-
if: ${{ matrix.os == 'windows-latest' }}
71-
run: cp /usr/include/FlexLexer.h /mingw64/include/FlexLexer.h
72-
7368
# Disable autocrlf for MSYS2 compatibility.
7469
- run: git config --global core.autocrlf input
7570
- uses: actions/checkout@v4
@@ -85,9 +80,6 @@ jobs:
8580
run: |
8681
echo "build-output-dir=$workspace/build" >> "$GITHUB_OUTPUT"
8782
88-
- name: Initialize and update submodules
89-
run: git submodule update --init --recursive
90-
9183
- name: Configure CMake
9284
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
9385
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type

.gitignore

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
.vscode/
2-
build/
3-
notes/
4-
*.dll
1+
/.vscode/
2+
/build/
3+
/notes/
54
*.glade~

.gitmodules

Lines changed: 0 additions & 3 deletions
This file was deleted.

CMakeLists.txt

Lines changed: 40 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2022-2023 Trevor Last
1+
# Copyright (C) 2022-2024 Trevor Last
22
#
33
# This program is free software: you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License as published by
@@ -13,115 +13,74 @@
1313
# You should have received a copy of the GNU General Public License
1414
# along with this program. If not, see <https://www.gnu.org/licenses/>.
1515

16-
cmake_minimum_required(VERSION 3.13)
16+
cmake_minimum_required(VERSION 3.31)
1717

1818
file(TO_CMAKE_PATH "${PROJECT_BINARY_DIR}/CMakeLists.txt" LOC_PATH)
1919
if(EXISTS "${LOC_PATH}")
2020
message(FATAL_ERROR "You cannot build in a source directory (or any directory with a CMakeLists.txt file). Please make a build subdirectory. Feel free to remove CMakeCache.txt and CMakeFiles.")
2121
endif()
2222

2323
project("Sickle Editor"
24-
VERSION 0.12.0
24+
VERSION 0.12.2
2525
DESCRIPTION "Open-Source GoldSrc Editor"
26-
LANGUAGES CXX
27-
)
26+
LANGUAGES CXX)
2827

2928
if(NOT CMAKE_BUILD_TYPE)
3029
message("CMAKE_BUILD_TYPE is unset, defaulting to Release")
3130
set(CMAKE_BUILD_TYPE Release)
3231
endif()
3332

33+
# MSYS2 only offers flex as a base package, but the compiler needs access to
34+
# the flex headers and libraries. Therefore we need to tell CMake to search for
35+
# flex in the MSYS2 /usr directory.
36+
if(WIN32)
37+
set(MSYS_PREFIX "C:/msys64" CACHE FILEPATH "path to the MSYS installation")
38+
set(FLEX_ROOT "${MSYS_PREFIX}/usr" CACHE FILEPATH "flex search root")
39+
endif()
3440

35-
set(CMAKE_CXX_STANDARD 17)
36-
set(CMAKE_CXX_STANDARD_REQUIRED ON)
37-
38-
39-
# Application ID
40-
set(APPLICATION_ID com.github.treecase.sicklegtk)
41-
# GResource prefix
42-
set(GRESOURCE_PREFIX /com/github/treecase/sicklegtk/)
43-
# GSchema path
44-
set(SCHEMA_DIR "${CMAKE_CURRENT_BINARY_DIR}")
4541

42+
# --- Dependencies --- ###########################
4643

47-
# Dependencies
48-
# glutils
49-
add_subdirectory(extern/glutils)
44+
include(FetchContent)
45+
FetchContent_Declare(
46+
glutils
47+
GIT_REPOSITORY https://github.com/Treecase/glutils
48+
GIT_TAG 59ad12bdfbd0f292fe56524ee72ece755b4771c5)
49+
FetchContent_MakeAvailable(glutils)
5050

51-
# GLEW
52-
find_package(GLEW REQUIRED)
51+
find_package(BISON 3.2 REQUIRED)
52+
find_package(FLEX 2.6 REQUIRED)
53+
find_package(GLEW 2.1 REQUIRED)
54+
find_package(glm 0.9 REQUIRED)
55+
find_package(Lua 5.4 REQUIRED)
5356

54-
# gtkmm3
5557
find_package(PkgConfig REQUIRED)
58+
pkg_check_modules(glibmm REQUIRED IMPORTED_TARGET glibmm-2.4)
5659
pkg_check_modules(GTKMM REQUIRED IMPORTED_TARGET gtkmm-3.0)
5760
pkg_check_modules(sigc++ REQUIRED IMPORTED_TARGET sigc++-2.0)
5861

59-
# GL library depends on platform, so define an alias for it
60-
add_library(SickleGL INTERFACE)
61-
if(WIN32)
62-
target_link_libraries(SickleGL INTERFACE OpenGL32)
63-
else()
64-
target_link_libraries(SickleGL INTERFACE GL)
65-
endif()
6662

63+
# --- Variables --- ##############################
64+
set(CMAKE_CXX_STANDARD 17)
65+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
6766

68-
# Configure files
69-
# Desktop file
70-
configure_file(sicklegtk.desktop.in ${APPLICATION_ID}.desktop)
71-
# Settings schema
72-
configure_file(sicklegtk.gschema.xml.in sicklegtk.gschema.xml)
67+
# Application ID
68+
set(APPLICATION_ID com.github.Treecase.SickleEditor)
69+
# GResource prefix
70+
set(GRESOURCE_PREFIX /com/github/Treecase/SickleEditor/)
71+
# GSchema path
72+
set(SCHEMA_DIR "${CMAKE_CURRENT_BINARY_DIR}")
7373

74-
include_directories(src)
7574

76-
# Declare targets
75+
# --- Target --- #################################
7776
add_executable(sickle)
78-
target_compile_features(sickle PRIVATE cxx_std_17)
79-
80-
# Compiles settings gschema
81-
add_custom_target(
82-
gschemas.compiled
83-
COMMAND
84-
glib-compile-schemas
85-
--strict
86-
--targetdir=.
87-
--schema-file=sicklegtk.gschema.xml
88-
)
89-
add_dependencies(sickle gschemas.compiled)
90-
91-
# Add .exe icon on Windows
92-
if(WIN32)
93-
add_subdirectory(windows)
94-
endif()
95-
96-
# Project sources
97-
add_subdirectory(src)
98-
# GResource data
99-
add_subdirectory(gresource)
77+
target_link_libraries(sickle PRIVATE ${CMAKE_DL_LIBS})
10078

79+
include(GNUInstallDirs)
10180

102-
# Linking
103-
if(MINGW)
104-
target_link_libraries(sickle PRIVATE mingw32)
105-
endif()
106-
target_link_libraries(sickle PRIVATE ${CMAKE_DL_LIBS})
81+
add_subdirectory(data)
82+
include_directories(sickle PUBLIC src)
83+
add_subdirectory(src)
10784

10885

109-
install(TARGETS sickle)
110-
install(DIRECTORY sickle TYPE DATA)
111-
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${APPLICATION_ID}.desktop"
112-
DESTINATION share/applications
113-
)
114-
if(WIN32)
115-
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/gschemas.compiled"
116-
DESTINATION share/glib-2.0/schemas
117-
)
118-
else()
119-
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/sicklegtk.gschema.xml"
120-
DESTINATION share/glib-2.0/schemas
121-
RENAME ${APPLICATION_ID}.gschema.xml
122-
)
123-
endif()
124-
install(FILES gresource/logo.svg
125-
DESTINATION share/icons/hicolor/scalable/apps
126-
RENAME ${APPLICATION_ID}.svg
127-
)
86+
install(TARGETS sickle)

README.md

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
21
# Sickle Editor
32

3+
![Build Status Badge](https://img.shields.io/github/actions/workflow/status/Treecase/SickleEditor/cmake-multi-platform.yml)
4+
![License Badge](https://img.shields.io/github/license/Treecase/SickleEditor)
5+
46
An open-source editor for GoldSrc maps. Both `.MAP` and `.RMF` formats are supported. Sickle Editor is released under the [GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html) license.
57

68

@@ -19,55 +21,60 @@ GoldSrc maps use external data files called WADs to store texture data. Sickle d
1921

2022
## Building
2123

22-
Sickle depends on [gtkmm-3](https://gtkmm.org/en/index.html) and [Lua 5.4](https://www.lua.org). You'll also need to have [flex](https://github.com/westes/flex) and [bison](https://www.gnu.org/software/bison) installed.
24+
### Linux
2325

24-
Before building, you must initialize the git submodules for the project:
26+
Make sure you install the required dependencies. For example, Debian/Ubuntu users can run:
2527

26-
```shell
27-
$ git submodule update --init --recursive
28+
```bash
29+
sudo apt install build-essential cmake bison flex git libglew-dev libglm-dev libgtkmm-3.0-dev liblua5.4-dev
2830
```
2931

30-
To build the program:
32+
And then build the program:
3133

32-
```shell
33-
$ mkdir build
34-
$ cd build
35-
$ cmake ..
36-
$ cmake --build .
34+
```bash
35+
git clone https://github.com/Treecase/SickleEditor
36+
cd SickleEditor
37+
cmake -B build .
38+
cmake --build build
3739
```
3840

3941
### Windows
4042

41-
Currently, only building with [mingw](https://www.mingw-w64.org) is supported. You may have to tell CMake to use the MinGW generator:
43+
Building on Windows requires [MSYS2](https://msys2.org). Note that this process is only tested with the UCRT64 environment (which is the default).
4244

43-
```shell
44-
$ mkdir build
45-
$ cd build
46-
$ cmake -G 'MinGW Makefiles' ..
47-
$ cmake --build .
45+
To start, install MSYS2 and open the UCRT64 shell. Run these commands to install the required dependencies:
46+
47+
```bash
48+
pacman -S mingw-w64-ucrt-x86_64-{toolchain,cmake,glew,glm,gtkmm3,lua}
49+
pacman -S bison flex git
4850
```
4951

50-
I also had some problems getting CMake to find Flex and Bison, and had to manually add the paths to `CMakeCache.txt`:
52+
To build the program:
5153

52-
```
53-
BISON_EXECUTABLE:FILEPATH=C:/msys64/usr/bin/bison.exe
54-
FLEX_EXECUTABLE:FILEPATH=C:/msys64/usr/bin/flex.exe
55-
FL_LIBRARY:FILEPATH=C:/msys64/usr/lib/libfl.a
54+
```bash
55+
git clone https://github.com/Treecase/SickleEditor
56+
cd SickleEditor
57+
cmake -B build .
58+
cmake --build build
5659
```
5760

5861

5962
## Installing
6063

61-
To install to `/usr/local`, run:
64+
To install the Sickle Editor, use:
65+
66+
```bash
67+
cmake --install build
68+
```
69+
70+
By default, the program will be installed to `/usr/local` on Linux and `C:/Program Files/Sickle Editor` on Windows. If you want the installation to go somewhere else, use:
6271

63-
```shell
64-
$ cmake --install .
65-
# To install somewhere else:
66-
$ cmake --install . --prefix=<install prefix>
72+
```bash
73+
cmake --install build --prefix=<Install Prefix>
6774
```
6875

69-
On Linux, you'll also have to install the settings schema:
76+
Linux users will also have to compile the GSettings schema with the following command.
7077

71-
```shell
72-
$ glib-compile-schemas <install prefix>/share/glib-2.0/schemas
78+
```bash
79+
glib-compile-schemas <Install Prefix>/share/glib-2.0/schemas
7380
```

data/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
add_subdirectory(gresource)
2+
add_subdirectory(share)
3+
if(WIN32)
4+
add_subdirectory(windows)
5+
endif()

0 commit comments

Comments
 (0)