Compare commits
8 Commits
caf8877307
...
lju/testin
| Author | SHA1 | Date | |
|---|---|---|---|
| f65d1099c2 | |||
| 110ff7ed7e | |||
| 0b70772009 | |||
| 2427601120 | |||
| c747dab1fc | |||
| 4c33da0ecd | |||
| f0284e7975 | |||
| 8f62ee83a6 |
@@ -1,21 +1,28 @@
|
|||||||
name: Gol CI
|
name: Gol CI
|
||||||
|
|
||||||
|
# Run on the merge of a pull request to the main branch
|
||||||
on:
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches: [main]
|
||||||
push:
|
push:
|
||||||
branches: [ main ]
|
branches: [main]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Install cmake
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y cmake
|
sudo apt-get install -y cmake libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libgl1-mesa-dev
|
||||||
- name: Build and test
|
- name: Build and test
|
||||||
run: |
|
run: |
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
cmake ..
|
cmake ..
|
||||||
make
|
make
|
||||||
|
- uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: gol-linux-build
|
||||||
|
path: /workspace/lejulien/GameOfLifeEditor/build/GameOfLifeEditor
|
||||||
|
|||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,8 +1,9 @@
|
|||||||
build
|
build
|
||||||
|
build_linux
|
||||||
|
build_win
|
||||||
enc_temp_folder
|
enc_temp_folder
|
||||||
out
|
out
|
||||||
_deps
|
_deps
|
||||||
CMakeSettings.json
|
CMakeSettings.json
|
||||||
.vs
|
.vs
|
||||||
.cache
|
.cache
|
||||||
build-win-x86_64
|
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ set(CMAKE_CXX_EXTENSIONS OFF)
|
|||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
set(IMGUI_BACKEND "imgui_impl_dx11.cpp") # DirectX 11 for Windows
|
#set(IMGUI_BACKEND "imgui_impl_dx11.cpp") # DirectX 11 for Windows
|
||||||
|
set(IMGUI_BACKEND "imgui_impl_opengl3.cpp") # OpenGL for Linux
|
||||||
elseif(APPLE)
|
elseif(APPLE)
|
||||||
set(IMGUI_BACKEND "imgui_impl_metal.mm") # Metal for macOS
|
set(IMGUI_BACKEND "imgui_impl_metal.mm") # Metal for macOS
|
||||||
elseif(UNIX)
|
elseif(UNIX)
|
||||||
|
|||||||
23
README.md
23
README.md
@@ -2,10 +2,16 @@
|
|||||||
|
|
||||||
This is a simple Game Of Life editor written in C++ with raylib & dearImGUI
|
This is a simple Game Of Life editor written in C++ with raylib & dearImGUI
|
||||||
|
|
||||||
***
|
---
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## How to compile the project
|
## How to compile the project
|
||||||
|
|
||||||
|
### Linux
|
||||||
|
|
||||||
Ensure you have g++, cmake and the dependencies of raylib
|
Ensure you have g++, cmake and the dependencies of raylib
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
@@ -15,4 +21,17 @@ cmake ..
|
|||||||
make
|
make
|
||||||
```
|
```
|
||||||
|
|
||||||
> As for now I will not make this program Windows compatible.
|
### Windows
|
||||||
|
|
||||||
|
If you're compiling for windows on linux, you can use mingw-w64
|
||||||
|
|
||||||
|
```shell
|
||||||
|
sudo apt install mingw-w64
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
cmake .. -DCMAKE_TOOLCHAIN_FILE=../toolchain-ming-w64-x86_64.cmake
|
||||||
|
make
|
||||||
|
```
|
||||||
|
If you're compiling for windows on windows, use your usual cmake workflow
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
BIN
preview.png
Normal file
BIN
preview.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 29 KiB |
97
src/main.cpp
97
src/main.cpp
@@ -6,11 +6,84 @@
|
|||||||
* ------
|
* ------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
// Prevent windows.h from defining many symbols that clash with raylib
|
||||||
|
#define NOGDICAPMASKS
|
||||||
|
#define NOVIRTUALKEYCODES
|
||||||
|
#define NOWINMESSAGES
|
||||||
|
#define NOWINSTYLES
|
||||||
|
#define NOSYSMETRICS
|
||||||
|
#define NOMENUS
|
||||||
|
#define NOICONS
|
||||||
|
#define NOKEYSTATES
|
||||||
|
#define NOSYSCOMMANDS
|
||||||
|
#define NORASTEROPS
|
||||||
|
#define NOSHOWWINDOW
|
||||||
|
#define OEMRESOURCE
|
||||||
|
#define NOATOM
|
||||||
|
#define NOCLIPBOARD
|
||||||
|
#define NOCOLOR
|
||||||
|
#define NOCTLMGR
|
||||||
|
#define NODRAWTEXT
|
||||||
|
#define NOGDI
|
||||||
|
#define NOKERNEL
|
||||||
|
#define NOUSER
|
||||||
|
#define NOMB
|
||||||
|
#define NOMEMMGR
|
||||||
|
#define NOMETAFILE
|
||||||
|
#define NOMINMAX
|
||||||
|
#define NOMSG
|
||||||
|
#define NOOPENFILE
|
||||||
|
#define NOSCROLL
|
||||||
|
#define NOSERVICE
|
||||||
|
#define NOSOUND
|
||||||
|
#define NOTEXTMETRIC
|
||||||
|
#define NOWH
|
||||||
|
#define NOWINOFFSETS
|
||||||
|
#define NOCOMM
|
||||||
|
#define NOKANJI
|
||||||
|
#define NOHELP
|
||||||
|
#define NOPROFILER
|
||||||
|
#define NODEFERWINDOWPOS
|
||||||
|
#define NOMCX
|
||||||
|
|
||||||
|
// Some code expects LPMSG; provide minimal typedef before windows.h
|
||||||
|
typedef struct tagMSG *LPMSG;
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
#undef PlaySound
|
||||||
|
// Define a minimal BITMAPINFOHEADER if needed by downstream code
|
||||||
|
typedef struct tagBITMAPINFOHEADER {
|
||||||
|
DWORD biSize;
|
||||||
|
LONG biWidth;
|
||||||
|
LONG biHeight;
|
||||||
|
WORD biPlanes;
|
||||||
|
WORD biBitCount;
|
||||||
|
DWORD biCompression;
|
||||||
|
DWORD biSizeImage;
|
||||||
|
LONG biXPelsPerMeter;
|
||||||
|
LONG biYPelsPerMeter;
|
||||||
|
DWORD biClrUsed;
|
||||||
|
DWORD biClrImportant;
|
||||||
|
} BITMAPINFOHEADER, *PBITMAPINFOHEADER;
|
||||||
|
|
||||||
|
#include <objbase.h>
|
||||||
|
#include <mmreg.h>
|
||||||
|
#include <mmsystem.h>
|
||||||
|
|
||||||
|
#if defined(_MSC_VER) || defined(__TINYC__)
|
||||||
|
#include "propidl.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#else
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <unistd.h>
|
|
||||||
#include <nlohmann/json.hpp>
|
|
||||||
|
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
#include <raylib.h>
|
#include <raylib.h>
|
||||||
#include <rlImGui.h>
|
#include <rlImGui.h>
|
||||||
@@ -86,11 +159,31 @@ int main(int ac, char **av) {
|
|||||||
|
|
||||||
// Get program directory
|
// Get program directory
|
||||||
char path_buf[1024];
|
char path_buf[1024];
|
||||||
|
#if defined(_WIN32)
|
||||||
|
std::wstring wbuf;
|
||||||
|
DWORD size = MAX_PATH;
|
||||||
|
for (;;) {
|
||||||
|
wbuf.resize(size);
|
||||||
|
DWORD result = GetModuleFileNameW(NULL, wbuf.data(), size);
|
||||||
|
if (result == 0) {
|
||||||
|
std::cerr << "Failed to determine program directory" << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (result < size) {
|
||||||
|
wbuf.resize(result);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
size *= 2;
|
||||||
|
}
|
||||||
|
path_buf[0] = '\0';
|
||||||
|
WideCharToMultiByte(CP_UTF8, 0, wbuf.c_str(), -1, path_buf, sizeof(path_buf), NULL, NULL);
|
||||||
|
#else
|
||||||
ssize_t len = readlink("/proc/self/exe", path_buf, sizeof(path_buf)-1);
|
ssize_t len = readlink("/proc/self/exe", path_buf, sizeof(path_buf)-1);
|
||||||
if (len == -1) {
|
if (len == -1) {
|
||||||
std::cerr << "Failed to determine program directory" << std::endl;
|
std::cerr << "Failed to determine program directory" << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
context->program_dir = std::filesystem::path(path_buf).parent_path();
|
context->program_dir = std::filesystem::path(path_buf).parent_path();
|
||||||
|
|
||||||
InitWindow(context->config_json["screen_width"], context->config_json["screen_height"],
|
InitWindow(context->config_json["screen_width"], context->config_json["screen_height"],
|
||||||
|
|||||||
@@ -35,8 +35,14 @@ void PaternsMenu::refresh() {
|
|||||||
std::filesystem::directory_iterator(paterns_path)) {
|
std::filesystem::directory_iterator(paterns_path)) {
|
||||||
if (!std::filesystem::is_directory(entry) &&
|
if (!std::filesystem::is_directory(entry) &&
|
||||||
entry.path().has_filename()) {
|
entry.path().has_filename()) {
|
||||||
|
#if defined(_WIN32)
|
||||||
|
paterns_paths_list_[entry.path().filename().string()] =
|
||||||
|
entry.path().string();
|
||||||
|
paterns_name_list_.push_back(entry.path().filename().string());
|
||||||
|
#else
|
||||||
paterns_paths_list_[entry.path().filename()] = entry.path();
|
paterns_paths_list_[entry.path().filename()] = entry.path();
|
||||||
paterns_name_list_.push_back(entry.path().filename());
|
paterns_name_list_.push_back(entry.path().filename());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user