@ -0,0 +1,31 @@ |
||||
{ |
||||
// Use IntelliSense to learn about possible attributes. |
||||
// Hover to view descriptions of existing attributes. |
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 |
||||
"version": "0.2.0", |
||||
"configurations": [{ |
||||
"preLaunchTask": "Build", |
||||
"name": "(gdb) Launch", |
||||
"type": "cppdbg", |
||||
"request": "launch", |
||||
"program": "${workspaceFolder}/C++ProjectTemplate", |
||||
"args": [], |
||||
"stopAtEntry": false, |
||||
"cwd": "${fileDirname}", |
||||
"environment": [], |
||||
"externalConsole": false, |
||||
"MIMode": "gdb", |
||||
"setupCommands": [ |
||||
{ |
||||
"description": "Enable pretty-printing for gdb", |
||||
"text": "-enable-pretty-printing", |
||||
"ignoreFailures": true |
||||
}, |
||||
{ |
||||
"description": "Set Disassembly Flavor to Intel", |
||||
"text": "-gdb-set disassembly-flavor intel", |
||||
"ignoreFailures": true |
||||
} |
||||
] |
||||
}] |
||||
} |
@ -0,0 +1,64 @@ |
||||
{ |
||||
"files.associations": { |
||||
"map1": "plaintext", |
||||
"iostream": "cpp", |
||||
"array": "cpp", |
||||
"atomic": "cpp", |
||||
"bit": "cpp", |
||||
"*.tcc": "cpp", |
||||
"cctype": "cpp", |
||||
"chrono": "cpp", |
||||
"clocale": "cpp", |
||||
"cmath": "cpp", |
||||
"codecvt": "cpp", |
||||
"compare": "cpp", |
||||
"concepts": "cpp", |
||||
"cstdarg": "cpp", |
||||
"cstddef": "cpp", |
||||
"cstdint": "cpp", |
||||
"cstdio": "cpp", |
||||
"cstdlib": "cpp", |
||||
"cstring": "cpp", |
||||
"ctime": "cpp", |
||||
"cwchar": "cpp", |
||||
"cwctype": "cpp", |
||||
"deque": "cpp", |
||||
"list": "cpp", |
||||
"map": "cpp", |
||||
"string": "cpp", |
||||
"unordered_map": "cpp", |
||||
"vector": "cpp", |
||||
"exception": "cpp", |
||||
"algorithm": "cpp", |
||||
"functional": "cpp", |
||||
"iterator": "cpp", |
||||
"memory": "cpp", |
||||
"memory_resource": "cpp", |
||||
"numeric": "cpp", |
||||
"random": "cpp", |
||||
"ratio": "cpp", |
||||
"string_view": "cpp", |
||||
"system_error": "cpp", |
||||
"tuple": "cpp", |
||||
"type_traits": "cpp", |
||||
"utility": "cpp", |
||||
"fstream": "cpp", |
||||
"initializer_list": "cpp", |
||||
"iomanip": "cpp", |
||||
"iosfwd": "cpp", |
||||
"istream": "cpp", |
||||
"limits": "cpp", |
||||
"new": "cpp", |
||||
"numbers": "cpp", |
||||
"ostream": "cpp", |
||||
"semaphore": "cpp", |
||||
"sstream": "cpp", |
||||
"stdexcept": "cpp", |
||||
"stop_token": "cpp", |
||||
"streambuf": "cpp", |
||||
"thread": "cpp", |
||||
"cinttypes": "cpp", |
||||
"typeinfo": "cpp", |
||||
"strstream": "cpp" |
||||
} |
||||
} |
@ -0,0 +1,18 @@ |
||||
{ |
||||
"version": "2.0.0", |
||||
"tasks": [ |
||||
{ |
||||
"label": "Build", |
||||
"command": "g++ *.cpp -std=c++17 -lX11 -lGL -lpthread -lpng -lstdc++fs -lpulse -lpulse-simple -o a.out", |
||||
"type": "shell", |
||||
"args": [], |
||||
"problemMatcher": [ |
||||
"$tsc" |
||||
], |
||||
"presentation": { |
||||
"reveal": "always" |
||||
}, |
||||
"group": "build" |
||||
} |
||||
] |
||||
} |
@ -0,0 +1,8 @@ |
||||
#include "Block.h" |
||||
|
||||
Block::Block(int x, int y, int R, int B, int G) |
||||
{ |
||||
X = x; |
||||
Y = y; |
||||
color = std::make_tuple(R, G, B); |
||||
} |
@ -0,0 +1,14 @@ |
||||
#pragma once |
||||
#include <tuple> |
||||
|
||||
class Block
|
||||
{ |
||||
public: |
||||
Block(){}; |
||||
Block(int x, int y, int R, int B, int G); |
||||
void display(float CameraX, float CameraY, float Zoom); |
||||
private: |
||||
int X; |
||||
int Y; |
||||
std::tuple<int, int, int> color; |
||||
}; |
@ -0,0 +1,17 @@ |
||||
#Compiles the entire program then runs it, producing an executable. If the "test" argument is included, will try and run tests too (in the test folder) |
||||
#C++ |
||||
printf "Running program...\n\n\n" |
||||
if [ "$1" = "test" ] |
||||
then |
||||
printf "Running tests...\n" |
||||
echo "#define TEST_SUITE" > ./test/test.h |
||||
if g++ $(find . -type f -name "*.cpp") ${CUSTOM_PARAMS} -o ${PROJECT_NAME}; then |
||||
./${PROJECT_NAME} "$@" |
||||
fi |
||||
else |
||||
echo "" > ./test/test.h |
||||
if g++ $(find . -type f -name "*.cpp" -not -path "./test/*") ${CUSTOM_PARAMS} -o ${PROJECT_NAME}; then |
||||
./${PROJECT_NAME} "$@" |
||||
fi |
||||
fi |
||||
printf "\n\n" |
@ -0,0 +1,20 @@ |
||||
#Adds a commit message and pushes project to github repository. |
||||
#C++ |
||||
COMMIT_MESSAGE="$*" |
||||
FIRST_LINE=true |
||||
while IFS= read -r line |
||||
do |
||||
if [ "$FIRST_LINE" = true ]; then |
||||
COMMIT_MESSAGE+=" |
||||
|
||||
Co-authored-by: $line" |
||||
FIRST_LINE=false |
||||
else |
||||
COMMIT_MESSAGE+=" |
||||
Co-authored-by: $line" |
||||
fi |
||||
done < utils/.coauthors |
||||
git add -u |
||||
git add * |
||||
git commit -m "$COMMIT_MESSAGE" |
||||
git push |
@ -0,0 +1,17 @@ |
||||
#Compiles the entire program with debug flags then runs it in gdb. If the "test" argument is included, will try and run tests too (in the test folder) |
||||
#C++ |
||||
printf "Running program...\n\n\n" |
||||
if [ "$1" = "test" ] |
||||
then |
||||
printf "Running tests...\n" |
||||
echo "#define TEST_SUITE" > ./test/test.h |
||||
if g++ $(find . -type f -name "*.cpp") -g ${CUSTOM_PARAMS} -o ${PROJECT_NAME}; then |
||||
gdb ./${PROJECT_NAME} "$@" |
||||
fi |
||||
else |
||||
echo "" > ./test/test.h |
||||
if g++ $(find . -type f -name "*.cpp" -not -path "./test/*") -g ${CUSTOM_PARAMS} -o ${PROJECT_NAME}; then |
||||
gdb ./${PROJECT_NAME} "$@" |
||||
fi |
||||
fi |
||||
printf "\n\n" |
@ -0,0 +1,7 @@ |
||||
build.sh |
||||
commit.sh |
||||
debug.sh |
||||
lines.sh |
||||
release.sh |
||||
temp |
||||
web.sh |
@ -0,0 +1,14 @@ |
||||
#Returns the line counts of your project. |
||||
#C++ |
||||
shopt -s extglob |
||||
ls -1 @(*.h|*.cpp) > temp |
||||
while read a; do |
||||
if [ "$a" != "pixelGameEngine.h" ] && [ "$a" != "soundwaveEngine.h" ] && [ "$a" != "splash.h" ]; |
||||
then |
||||
echo -e "$a\n" >> temp2 |
||||
fi |
||||
done < temp |
||||
wc -l $(cat temp2) |
||||
|
||||
rm temp |
||||
rm temp2 |
@ -0,0 +1,7 @@ |
||||
build.sh:6fbec04ed16be42bab846f1eed603133 - |
||||
commit.sh:d03a46e721060c22ccb146e19d27e70a - |
||||
debug.sh:7f57c6640be5f262988961c3b45dce97 - |
||||
lines.sh:3b907786f7fc9204025993016c9080de - |
||||
release.sh:0a525311cc14b9c8aefc6f2b816129a1 - |
||||
temp:d41d8cd98f00b204e9800998ecf8427e - |
||||
web.sh:96f2c316536011a3defac50aecae487d - |
@ -0,0 +1,7 @@ |
||||
#Creates a release build that focuses on high runtime performance. |
||||
#C++ |
||||
printf "Running program...\n\n\n" |
||||
if g++ $(find . -type f -name "*.cpp" -not -path "./test/*") ${CUSTOM_PARAMS} -O3 -s -DNDEBUG -o ${PROJECT_NAME}; then |
||||
./${PROJECT_NAME} "$@" |
||||
fi |
||||
printf "\n\n" |
@ -0,0 +1,18 @@ |
||||
#Compiles emscripten instance of this project for the web. |
||||
#C++ |
||||
if [ -d "assets" ]; then |
||||
em++ -std=c++17 -O2 -s ALLOW_MEMORY_GROWTH=1 -s MAX_WEBGL_VERSION=2 -s MIN_WEBGL_VERSION=2 -s USE_SDL_MIXER=2 -s USE_LIBPNG=1 $(find . -type f -name "*.cpp" -not -path "./test/*") -o ${PROJECT_NAME}.html -I pixelGameEngine.h --preload-file ./assets |
||||
else |
||||
em++ -std=c++17 -O2 -s ALLOW_MEMORY_GROWTH=1 -s MAX_WEBGL_VERSION=2 -s MIN_WEBGL_VERSION=2 -s USE_SDL_MIXER=2 -s USE_LIBPNG=1 $(find . -type f -name "*.cpp" -not -path "./test/*") -o ${PROJECT_NAME}.html -I pixelGameEngine.h |
||||
fi |
||||
|
||||
cp buildtemplate.html ${PROJECT_NAME}.html |
||||
sed -i "s/_REPLACEME_/$PROJECT_NAME.js/" ${PROJECT_NAME}.html |
||||
|
||||
if [ "$1" == "headless" ]; then |
||||
echo "Running as headless web server" |
||||
emrun --no_browser ${PROJECT_NAME}.html |
||||
else |
||||
emrun --serve_after_close ${PROJECT_NAME}.html |
||||
fi |
||||
|
@ -0,0 +1,75 @@ |
||||
|
||||
<!doctype html> |
||||
<html lang="en-us"> |
||||
<head> |
||||
<meta name="viewport" content="width=device-width, initial-scale=1"> |
||||
<meta charset="utf-8"> |
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
||||
<title>Emscripten-Generated Code</title> |
||||
<style> |
||||
html,body { width: 100%; height: 100%; } |
||||
body { font-family: arial; margin: 0; padding: 0; background: #000; } |
||||
|
||||
.emscripten { padding-right: 0; margin-left: auto; margin-right: auto; display: block; } |
||||
div.emscripten_border { border: none; } |
||||
|
||||
/* the canvas *must not* have any border or padding, or mouse coords will be wrong */ |
||||
canvas.emscripten { border: 0px none; background-color: black; } |
||||
</style> |
||||
</head> |
||||
<body> |
||||
<canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()" tabindex=-1></canvas> |
||||
<script type='text/javascript'> |
||||
var Module = { |
||||
preRun: [], |
||||
postRun: [], |
||||
canvas: (function() { |
||||
var canvas = document.getElementById('canvas'); |
||||
|
||||
// As a default initial behavior, pop up an alert when webgl context is lost. To make your |
||||
// application robust, you may want to override this behavior before shipping! |
||||
// See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2 |
||||
canvas.addEventListener("webglcontextlost", function(e) { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false); |
||||
|
||||
return canvas; |
||||
})(), |
||||
}; |
||||
</script> |
||||
<script async type="text/javascript" src="C++ProjectTemplate.js"></script> |
||||
<script type="text/javascript"> |
||||
Module.canvas.addEventListener("resize", (e) => { |
||||
|
||||
var viewWidth = e.detail.width; |
||||
var viewHeight = e.detail.width / Module._olc_WindowAspectRatio; |
||||
|
||||
if(viewHeight > e.detail.height) |
||||
{ |
||||
viewHeight = e.detail.height; |
||||
viewWidth = e.detail.height * Module._olc_WindowAspectRatio; |
||||
} |
||||
|
||||
// update dom attributes |
||||
Module.canvas.setAttribute("width", viewWidth); |
||||
Module.canvas.setAttribute("height", viewHeight); |
||||
|
||||
var top = (e.detail.height - viewHeight) / 2; |
||||
var left = (e.detail.width - viewWidth) / 2; |
||||
|
||||
// update styles |
||||
Module.canvas.style.position = "fixed"; |
||||
Module.canvas.style.top = top.toString() + "px"; |
||||
Module.canvas.style.left = left.toString() + "px"; |
||||
Module.canvas.style.width = ""; |
||||
Module.canvas.style.height = ""; |
||||
|
||||
// trigger PGE update |
||||
Module._olc_PGE_UpdateWindowSize(viewWidth, viewHeight); |
||||
|
||||
// ensure canvas has focus |
||||
Module.canvas.focus(); |
||||
e.preventDefault(); |
||||
}); |
||||
</script> |
||||
|
||||
</body> |
||||
</html> |
@ -0,0 +1,33 @@ |
||||
This repository contains general build scripts and pipelines for all languages that I incorporate in my projects. The goal is to provide an easy retrieval and update system for the project. Each script will be a shell script containing the following template: |
||||
```bash |
||||
#Short description about what I do |
||||
#Language[Folder] |
||||
# #The script's code goes in here. |
||||
# rm -Rf out/* |
||||
# javac -Xlint:unchecked -cp ${PROJECT_DIR}/.. -d ${OUT_DIR} ${PROJECT_DIR}/*.java |
||||
# printf "\n\n\nRunning Program...\n\n" |
||||
# cd $OUT_DIR |
||||
# java ${MAIN_CLASS} "$@" |
||||
# ../scripts/clean.sh |
||||
|
||||
``` |
||||
Each language will be in the following structure: |
||||
``` |
||||
-<Language> |
||||
--<scripts> |
||||
---[script files.sh] |
||||
``` |
||||
|
||||
The `sig` script will display by default any scripts in the `scripts` folder, therefore when creating a project, copy over the scripts folder of the desired language into your project then the `sig` script handles the rest appropriately. If your project requires multiple languages and build setups, then you can use the `sig2` command, which has an additional parameter to specify the language when running it. When setting up a multi-language setup, you'll just copy the entire folder to include the programming language itself. So a multi-language project structure may look something like this: |
||||
``` |
||||
-C |
||||
--scripts |
||||
---build.sh |
||||
---clean.sh |
||||
---make.sh |
||||
-Java |
||||
--scripts |
||||
---build.sh |
||||
---clean.sh |
||||
---jar.sh |
||||
``` |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 662 B |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 2.4 KiB |
After Width: | Height: | Size: 2.4 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 363 B |
After Width: | Height: | Size: 329 B |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 3.5 KiB |
After Width: | Height: | Size: 4.7 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 892 B |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 477 KiB |
After Width: | Height: | Size: 495 KiB |
After Width: | Height: | Size: 83 KiB |
After Width: | Height: | Size: 569 KiB |
After Width: | Height: | Size: 147 KiB |
After Width: | Height: | Size: 106 KiB |
After Width: | Height: | Size: 334 KiB |
After Width: | Height: | Size: 75 KiB |
After Width: | Height: | Size: 85 KiB |
After Width: | Height: | Size: 333 KiB |
After Width: | Height: | Size: 105 KiB |
After Width: | Height: | Size: 86 KiB |
After Width: | Height: | Size: 116 KiB |
After Width: | Height: | Size: 441 KiB |
After Width: | Height: | Size: 116 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 3.1 KiB |
After Width: | Height: | Size: 105 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 7.3 KiB |
@ -0,0 +1,75 @@ |
||||
|
||||
<!doctype html> |
||||
<html lang="en-us"> |
||||
<head> |
||||
<meta name="viewport" content="width=device-width, initial-scale=1"> |
||||
<meta charset="utf-8"> |
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
||||
<title>Emscripten-Generated Code</title> |
||||
<style> |
||||
html,body { width: 100%; height: 100%; } |
||||
body { font-family: arial; margin: 0; padding: 0; background: #000; } |
||||
|
||||
.emscripten { padding-right: 0; margin-left: auto; margin-right: auto; display: block; } |
||||
div.emscripten_border { border: none; } |
||||
|
||||
/* the canvas *must not* have any border or padding, or mouse coords will be wrong */ |
||||
canvas.emscripten { border: 0px none; background-color: black; } |
||||
</style> |
||||
</head> |
||||
<body> |
||||
<canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()" tabindex=-1></canvas> |
||||
<script type='text/javascript'> |
||||
var Module = { |
||||
preRun: [], |
||||
postRun: [], |
||||
canvas: (function() { |
||||
var canvas = document.getElementById('canvas'); |
||||
|
||||
// As a default initial behavior, pop up an alert when webgl context is lost. To make your |
||||
// application robust, you may want to override this behavior before shipping! |
||||
// See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2 |
||||
canvas.addEventListener("webglcontextlost", function(e) { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false); |
||||
|
||||
return canvas; |
||||
})(), |
||||
}; |
||||
</script> |
||||
<script async type="text/javascript" src="_REPLACEME_"></script> |
||||
<script type="text/javascript"> |
||||
Module.canvas.addEventListener("resize", (e) => { |
||||
|
||||
var viewWidth = e.detail.width; |
||||
var viewHeight = e.detail.width / Module._olc_WindowAspectRatio; |
||||
|
||||
if(viewHeight > e.detail.height) |
||||
{ |
||||
viewHeight = e.detail.height; |
||||
viewWidth = e.detail.height * Module._olc_WindowAspectRatio; |
||||
} |
||||
|
||||
// update dom attributes |
||||
Module.canvas.setAttribute("width", viewWidth); |
||||
Module.canvas.setAttribute("height", viewHeight); |
||||
|
||||
var top = (e.detail.height - viewHeight) / 2; |
||||
var left = (e.detail.width - viewWidth) / 2; |
||||
|
||||
// update styles |
||||
Module.canvas.style.position = "fixed"; |
||||
Module.canvas.style.top = top.toString() + "px"; |
||||
Module.canvas.style.left = left.toString() + "px"; |
||||
Module.canvas.style.width = ""; |
||||
Module.canvas.style.height = ""; |
||||
|
||||
// trigger PGE update |
||||
Module._olc_PGE_UpdateWindowSize(viewWidth, viewHeight); |
||||
|
||||
// ensure canvas has focus |
||||
Module.canvas.focus(); |
||||
e.preventDefault(); |
||||
}); |
||||
</script> |
||||
|
||||
</body> |
||||
</html> |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 699 B |
@ -0,0 +1,53 @@ |
||||
// The MIT License (MIT)
|
||||
|
||||
// Copyright (c) 2013-2020 Rapptz, ThePhD and contributors
|
||||
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
// this software and associated documentation files (the "Software"), to deal in
|
||||
// the Software without restriction, including without limitation the rights to
|
||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
// the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
// subject to the following conditions:
|
||||
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// This file was generated with a script.
|
||||
// Generated 2022-10-23 03:24:40.304940 UTC
|
||||
// This header was generated with sol v3.3.0 (revision 0386513a)
|
||||
// https://github.com/ThePhD/sol2
|
||||
|
||||
#ifndef SOL_SINGLE_CONFIG_HPP |
||||
#define SOL_SINGLE_CONFIG_HPP |
||||
|
||||
// beginning of sol/config.hpp
|
||||
|
||||
/* Base, empty configuration file!
|
||||
|
||||
To override, place a file in your include paths of the form: |
||||
|
||||
. (your include path here) |
||||
| sol (directory, or equivalent) |
||||
| config.hpp (your config.hpp file) |
||||
|
||||
So that when sol2 includes the file |
||||
|
||||
#include <sol/config.hpp> |
||||
|
||||
it gives you the configuration values you desire. Configuration values can be |
||||
seen in the safety.rst of the doc/src, or at |
||||
https://sol2.readthedocs.io/en/latest/safety.html ! You can also pass them through
|
||||
the build system, or the command line options of your compiler. |
||||
|
||||
*/ |
||||
|
||||
// end of sol/config.hpp
|
||||
|
||||
#endif // SOL_SINGLE_CONFIG_HPP
|
@ -0,0 +1,33 @@ |
||||
return |
||||
{ |
||||
Name = "Weapon", -- used for Engine::GetResearch() |
||||
offset = {0,0}, |
||||
Icon = |
||||
{ |
||||
FileName = "Assets/Research/Icons/WeaponUpgradeIcon.png",--Maybe Have multi_Icon based on lvl of upgrade? |
||||
size = {32,32}, |
||||
FileSize = {64,64} |
||||
}, |
||||
Parameters = |
||||
{ |
||||
Oncer = false, --Only get one upgrade |
||||
InitialCost = 120, |
||||
CostScale = 2, --How Much more it costs per upgrade??? Use Math Equation |
||||
ResearchTime = 22 --Seconds |
||||
}, |
||||
Requirements = |
||||
{ |
||||
Buildings = {"Castle","StoneTower"} |
||||
}, |
||||
Reward = |
||||
{ |
||||
Stats = |
||||
{ |
||||
Damage = 5, |
||||
Armor = 5, |
||||
Health = 10, |
||||
MoveSpeed= 4 |
||||
}, |
||||
Unlocks = {"Archer"} |
||||
} |
||||
} |
@ -0,0 +1,14 @@ |
||||
1114d1113 |
||||
< void SetFPSDisplay(bool display); |
||||
1176,1177c1175 |
||||
< int nFrameCount = 0; |
||||
< bool showFPS = true; |
||||
--- |
||||
> int nFrameCount = 0; |
||||
3203,3204d3200 |
||||
< void PixelGameEngine::SetFPSDisplay(bool display) |
||||
< { showFPS=display; } |
||||
3543c3539 |
||||
< std::string sTitle = "OneLoneCoder.com - Pixel Game Engine - " + sAppName + ((showFPS)?" - FPS: " + std::to_string(nFrameCount):""); |
||||
--- |
||||
> std::string sTitle = "OneLoneCoder.com - Pixel Game Engine - " + sAppName + " - FPS: " + std::to_string(nFrameCount); |
After Width: | Height: | Size: 35 KiB |
After Width: | Height: | Size: 2.5 KiB |
@ -0,0 +1,188 @@ |
||||
#define OLC_PGE_APPLICATION |
||||
#include "pixelGameEngine.h" |
||||
|
||||
// PGEX Require the presence of olc::PixelGameEngine
|
||||
#define OLC_PGEX_QUICKGUI |
||||
#include "quickgui.h" |
||||
|
||||
namespace olc::QuickGUI{ |
||||
class PictureBox : public olc::QuickGUI::BaseControl{ |
||||
private: |
||||
olc::vi2d clickPos; |
||||
public: |
||||
PictureBox(olc::QuickGUI::Manager& manager, // Associate with a Manager
|
||||
const olc::vf2d& pos, |
||||
const olc::vf2d& size, |
||||
const olc::vf2d& offset, |
||||
olc::Renderable& image); |
||||
|
||||
public: |
||||
// Minium value
|
||||
olc::vf2d offset; |
||||
olc::vf2d pos; |
||||
olc::vf2d size; |
||||
olc::Renderableℑ |
||||
|
||||
public: // BaseControl overrides
|
||||
void Update(olc::PixelGameEngine* pge) override; |
||||
void Draw(olc::PixelGameEngine* pge) override; |
||||
void DrawDecal(olc::PixelGameEngine* pge) override; |
||||
}; |
||||
|
||||
PictureBox::PictureBox(olc::QuickGUI::Manager& manager, const olc::vf2d& pos, const olc::vf2d& size, const olc::vf2d& offset,olc::Renderable& image)
|
||||
: BaseControl(manager),pos(pos),size(size),offset(offset),image(image){} |
||||
|
||||
void PictureBox::Update(olc::PixelGameEngine* pge) |
||||
{ |
||||
bPressed = false; |
||||
bReleased = false; |
||||
float fElapsedTime = pge->GetElapsedTime(); |
||||
|
||||
olc::vf2d vMouse = pge->GetMousePos(); |
||||
if (m_state != State::Click) |
||||
{ |
||||
if (vMouse.x >= pos.x && vMouse.x < pos.x + size.x && |
||||
vMouse.y >= pos.y && vMouse.y < pos.y + size.y) |
||||
{ |
||||
m_fTransition += fElapsedTime * m_manager.fHoverSpeedOn; |
||||
m_state = State::Hover; |
||||
|
||||
bPressed = pge->GetMouse(olc::Mouse::LEFT).bPressed;
|
||||
if (bPressed) |
||||
{ |
||||
m_state = State::Click; |
||||
clickPos = vMouse; |
||||
} |
||||
|
||||
bHeld = pge->GetMouse(olc::Mouse::LEFT).bHeld; |
||||
} |
||||
else |
||||
{ |
||||
m_fTransition -= fElapsedTime * m_manager.fHoverSpeedOff; |
||||
m_state = State::Normal; |
||||
} |
||||
} |
||||
else |
||||
{
|
||||
bHeld = pge->GetMouse(olc::Mouse::LEFT).bHeld; |
||||
bReleased = pge->GetMouse(olc::Mouse::LEFT).bReleased; |
||||
if (bReleased) m_state = State::Normal; |
||||
offset+=clickPos-vMouse; |
||||
offset.x=std::clamp((int)offset.x,0,image.Sprite()->width-(int)size.x); |
||||
offset.y=std::clamp((int)offset.y,0,image.Sprite()->height-(int)size.y); |
||||
clickPos=vMouse; |
||||
} |
||||
} |
||||
|
||||
void PictureBox::Draw(olc::PixelGameEngine* pge) |
||||
{ |
||||
if (!bVisible) |
||||
return; |
||||
switch (m_state) |
||||
{ |
||||
case State::Disabled: { |
||||
pge->FillRect(pos,size,m_manager.colDisable); |
||||
}break; |
||||
case State::Normal: |
||||
case State::Hover: { |
||||
pge->FillRect(pos,size,olc::PixelLerp(m_manager.colNormal, m_manager.colHover, m_fTransition)); |
||||
}break; |
||||
case State::Click: { |
||||
pge->FillRect(pos,size,m_manager.colClick); |
||||
}break; |
||||
} |
||||
pge->DrawPartialSprite({(int)pos.x+1,(int)pos.y+1},image.Sprite(),offset,{(int)size.x-2,(int)size.y-2}); |
||||
pge->DrawRect(pos,size,m_manager.colBorder); |
||||
} |
||||
|
||||
void PictureBox::DrawDecal(olc::PixelGameEngine* pge) |
||||
{ |
||||
if (!bVisible) |
||||
return; |
||||
|
||||
switch (m_state) |
||||
{ |
||||
case State::Disabled: { |
||||
pge->FillRectDecal(pos,size,olc::PixelLerp(m_manager.colNormal, m_manager.colHover, m_fTransition)); |
||||
}break; |
||||
case State::Normal: |
||||
case State::Hover: { |
||||
pge->FillRectDecal(pos,size,olc::PixelLerp(m_manager.colNormal, m_manager.colHover, m_fTransition)); |
||||
}break; |
||||
case State::Click: { |
||||
pge->FillRectDecal(pos,size,m_manager.colClick); |
||||
}break; |
||||
} |
||||
pge->DrawPartialDecal({pos.x+1,pos.y+1},image.Decal(),offset,{size.x-2,size.y-2}); |
||||
pge->SetDecalMode(olc::DecalMode::WIREFRAME); |
||||
pge->DrawRectDecal(pos,size,m_manager.colBorder); |
||||
pge->SetDecalMode(olc::DecalMode::NORMAL); |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
class olcDemo_QuickGUI : public olc::PixelGameEngine |
||||
{ |
||||
public: |
||||
olcDemo_QuickGUI() |
||||
{ |
||||
sAppName = "olcDemo_QuickGUI"; |
||||
} |
||||
|
||||
protected: |
||||
olc::QuickGUI::Manager guiManager; |
||||
|
||||
olc::QuickGUI::PictureBox* pictureBox = nullptr; |
||||
olc::QuickGUI::Slider* pictureBoxSliderX = nullptr; |
||||
olc::QuickGUI::Slider* pictureBoxSliderY = nullptr; |
||||
olc::Renderable dirtimg; |
||||
|
||||
public: |
||||
bool OnUserCreate() override |
||||
{ |
||||
dirtimg.Load("dirtblock.png"); |
||||
|
||||
pictureBox = new olc::QuickGUI::PictureBox(guiManager,
|
||||
{ 10.0f, 10.0f }, { 128.0f, 128.0f }, {0,0}, dirtimg); |
||||
pictureBoxSliderX = new olc::QuickGUI::Slider(guiManager,{pictureBox->pos.x,pictureBox->pos.y+pictureBox->size.y+16},{pictureBox->pos.x+pictureBox->size.x,pictureBox->pos.y+pictureBox->size.y+16}, |
||||
0,pictureBox->image.Sprite()->width-(int)pictureBox->size.x,pictureBox->offset.x); |
||||
pictureBoxSliderY = new olc::QuickGUI::Slider(guiManager,{pictureBox->pos.x+pictureBox->size.x+16,pictureBox->pos.y},{pictureBox->pos.x+pictureBox->size.x+16,pictureBox->pos.y+pictureBox->size.y}, |
||||
0,pictureBox->image.Sprite()->height-(int)pictureBox->size.y,pictureBox->offset.y); |
||||
|
||||
guiManager.AddControl(pictureBox); |
||||
guiManager.AddControl(pictureBoxSliderX); |
||||
return true; |
||||
} |
||||
|
||||
bool OnUserUpdate(float fElapsedTime) override |
||||
{ |
||||
guiManager.Update(this); |
||||
|
||||
if (pictureBoxSliderX->bHeld) { |
||||
pictureBox->offset.x=pictureBoxSliderX->fValue; |
||||
} else { |
||||
pictureBoxSliderX->fValue=pictureBox->offset.x; |
||||
} |
||||
|
||||
if (pictureBoxSliderY->bHeld) { |
||||
pictureBox->offset.y=pictureBoxSliderY->fValue; |
||||
} else { |
||||
pictureBoxSliderY->fValue=pictureBox->offset.y; |
||||
} |
||||
|
||||
// Draw Stuff!
|
||||
Clear(olc::BLACK); |
||||
|
||||
guiManager.DrawDecal(this); |
||||
return true; |
||||
} |
||||
}; |
||||
|
||||
int main() |
||||
{ |
||||
olcDemo_QuickGUI demo; |
||||
if (demo.Construct(256, 240, 4, 4)) |
||||
demo.Start(); |
||||
return 0; |
||||
} |
@ -0,0 +1,786 @@ |
||||
/*
|
||||
OneLoneCoder - QuickGUI v1.00 |
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||||
A semi-immediate mode GUI for very simple GUI stuff.
|
||||
Includes: |
||||
Label - Displays a single-line string |
||||
TextBox - Click to enter/edit single-line text |
||||
Button - A clickable labelled rectangle |
||||
CheckBox - A clickable labelled rectangle that retains state |
||||
Slider - An omnidirectional draggable handle between two values |
||||
|
||||
License (OLC-3) |
||||
~~~~~~~~~~~~~~~ |
||||
|
||||
Copyright 2018 - 2021 OneLoneCoder.com |
||||
|
||||
Redistribution and use in source and binary forms, with or without |
||||
modification, are permitted provided that the following conditions |
||||
are met: |
||||
|
||||
1. Redistributions or derivations of source code must retain the above |
||||
copyright notice, this list of conditions and the following disclaimer. |
||||
|
||||
2. Redistributions or derivative works in binary form must reproduce |
||||
the above copyright notice. This list of conditions and the following |
||||
disclaimer must be reproduced in the documentation and/or other |
||||
materials provided with the distribution. |
||||
|
||||
3. Neither the name of the copyright holder nor the names of its |
||||
contributors may be used to endorse or promote products derived |
||||
from this software without specific prior written permission. |
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
|
||||
Links |
||||
~~~~~ |
||||
YouTube: https://www.youtube.com/javidx9
|
||||
Discord: https://discord.gg/WhwHUMV
|
||||
Twitter: https://www.twitter.com/javidx9
|
||||
Twitch: https://www.twitch.tv/javidx9
|
||||
GitHub: https://www.github.com/onelonecoder
|
||||
Homepage: https://www.onelonecoder.com
|
||||
|
||||
Author |
||||
~~~~~~ |
||||
David Barr, aka javidx9, ©OneLoneCoder 2019, 2020, 2021, 2022 |
||||
|
||||
*/ |
||||
|
||||
#ifndef OLC_PGEX_QUICKGUI_H |
||||
#define OLC_PGEX_QUICKGUI_H |
||||
|
||||
#include "pixelGameEngine.h" |
||||
|
||||
|
||||
namespace olc::QuickGUI |
||||
{ |
||||
class Manager; |
||||
|
||||
// Virtual base class for all controls
|
||||
class BaseControl |
||||
{ |
||||
public: |
||||
BaseControl(olc::QuickGUI::Manager& manager); |
||||
virtual ~BaseControl(); |
||||
|
||||
public: |
||||
// Switches the control on/off
|
||||
void Enable(const bool bEnable); |
||||
// Sets whether or not the control is interactive/displayed
|
||||
bool bVisible = true; |
||||
|
||||
// True on single frame control begins being manipulated
|
||||
bool bPressed = false; |
||||
// True on all frames control is under user manipulation
|
||||
bool bHeld = false; |
||||
// True on single frame control ceases being manipulated
|
||||
bool bReleased = false; |
||||
|
||||
public: |
||||
// Updates the controls behvaiour
|
||||
virtual void Update(olc::PixelGameEngine* pge) = 0; |
||||
// Draws the control using "sprite" based CPU operations
|
||||
virtual void Draw(olc::PixelGameEngine* pge) = 0; |
||||
// Draws the control using "decal" based GPU operations
|
||||
virtual void DrawDecal(olc::PixelGameEngine* pge) = 0; |
||||
|
||||
protected: |
||||
// Controls are related to a manager, where the theme resides
|
||||
// and control groups can be implemented
|
||||
olc::QuickGUI::Manager& m_manager; |
||||
|
||||
// All controls exists in one of four states
|
||||
// Disabled - Greyed out and not interactive
|
||||
// Normal - interactive and operational
|
||||
// Hover - currently under the users mouse focus
|
||||
// Click - user is interacting with the control
|
||||
enum class State { Disabled, Normal, Hover, Click } m_state = State::Normal; |
||||
|
||||
// To add a "swish" to things, controls can fade between states
|
||||
float m_fTransition = 0.0; |
||||
}; |
||||
|
||||
|
||||
// A QuickGUI::Manager acts as a convenient grouping of controls
|
||||
class Manager |
||||
{ |
||||
public: |
||||
// Construct Manager, bCleanUpForMe will automatically DELETE any controls
|
||||
// given to this manager via AddControl() if true
|
||||
Manager(const bool bCleanUpForMe = true); |
||||
virtual ~Manager(); |
||||
|
||||
public: |
||||
// Add a gui element derived form BaseControl to this manager
|
||||
void AddControl(BaseControl* control); |
||||
// Updates all controls this manager operates
|
||||
void Update(olc::PixelGameEngine* pge); |
||||
// Draws as "sprite" all controls this manager operates
|
||||
void Draw(olc::PixelGameEngine* pge); |
||||
// Draws as "decal" all controls this manager operates
|
||||
void DrawDecal(olc::PixelGameEngine* pge); |
||||
|
||||
public: // This managers "Theme" can be set here
|
||||
// Various element colours
|
||||
olc::Pixel colNormal = olc::DARK_BLUE; |
||||
olc::Pixel colHover = olc::BLUE; |
||||
olc::Pixel colClick = olc::CYAN; |
||||
olc::Pixel colDisable = olc::DARK_GREY; |
||||
olc::Pixel colBorder = olc::WHITE; |
||||
olc::Pixel colText = olc::WHITE; |
||||
// Speed to transiton from Normal -> Hover
|
||||
float fHoverSpeedOn = 10.0f; |
||||
// Speed to transiton from Hover -> Normal
|
||||
float fHoverSpeedOff = 4.0f; |
||||
|
||||
private: |
||||
// Should this manager call delete on the controls it opeerates?
|
||||
bool m_bEraseControlsOnDestroy = true; |
||||
// Container of controls
|
||||
std::vector<BaseControl*> m_vControls; |
||||
}; |
||||
|
||||
|
||||
// Creates a Label Control - it's just text!
|
||||
class Label : public BaseControl |
||||
{ |
||||
public: |
||||
Label(olc::QuickGUI::Manager& manager, // Associate with a Manager
|
||||
const std::string& text, // Text to display
|
||||
const olc::vf2d& pos, // Location of label top-left
|
||||
const olc::vf2d& size); // Size of label
|
||||
|
||||
public: |
||||
// Position of button
|
||||
olc::vf2d vPos; |
||||
// Size of button
|
||||
olc::vf2d vSize; |
||||
// Text displayed on button
|
||||
std::string sText; |
||||
// Show a border?
|
||||
bool bHasBorder = false; |
||||
// Show a background?
|
||||
bool bHasBackground = false; |
||||
// Where should the text be positioned?
|
||||
enum class Alignment |
||||
{Left, Centre, Right} nAlign = Alignment::Centre; |
||||
|
||||
public: // BaseControl overrides
|
||||
void Update(olc::PixelGameEngine* pge) override; |
||||
void Draw(olc::PixelGameEngine* pge) override; |
||||
void DrawDecal(olc::PixelGameEngine* pge) override; |
||||
}; |
||||
|
||||
class TextBox : public Label |
||||
{ |
||||
public: |
||||
TextBox(olc::QuickGUI::Manager& manager, // Associate with a Manager
|
||||
const std::string& text, // Text to display
|
||||
const olc::vf2d& pos, // Location of text box top-left
|
||||
const olc::vf2d& size); // Size of text box
|
||||
|
||||
public: // BaseControl overrides
|
||||
void Update(olc::PixelGameEngine* pge) override; |
||||
void Draw(olc::PixelGameEngine* pge) override; |
||||
void DrawDecal(olc::PixelGameEngine* pge) override; |
||||
|
||||
protected: |
||||
bool m_bTextEdit = false; |
||||
|
||||
}; |
||||
|
||||
// Creates a Button Control - a clickable, labelled rectangle
|
||||
class Button : public BaseControl |
||||
{ |
||||
public: |
||||
Button(olc::QuickGUI::Manager& manager, // Associate with a Manager
|
||||
const std::string& text, // Text to display
|
||||
const olc::vf2d& pos, // Location of button top-left
|
||||
const olc::vf2d& size); // Size of button
|
||||
|
||||
public: |
||||
// Position of button
|
||||
olc::vf2d vPos;
|
||||
// Size of button
|
||||
olc::vf2d vSize; |
||||
// Text displayed on button
|
||||
std::string sText; |
||||
|
||||
public: // BaseControl overrides
|
||||
void Update(olc::PixelGameEngine* pge) override; |
||||
void Draw(olc::PixelGameEngine* pge) override; |
||||
void DrawDecal(olc::PixelGameEngine* pge) override; |
||||
}; |
||||
|
||||
// Creates a Button Control - a clickable, labelled rectangle
|
||||
class CheckBox : public Button |
||||
{ |
||||
public: |
||||
CheckBox(olc::QuickGUI::Manager& manager, // Associate with a Manager
|
||||
const std::string& text, // Text to display
|
||||
const bool check, // Is checked or not?
|
||||
const olc::vf2d& pos, // Location of button top-left
|
||||
const olc::vf2d& size); // Size of button
|
||||
|
||||
public: |
||||
bool bChecked = false; |
||||
|
||||
public: // BaseControl overrides
|
||||
void Update(olc::PixelGameEngine* pge) override; |
||||
void Draw(olc::PixelGameEngine* pge) override; |
||||
void DrawDecal(olc::PixelGameEngine* pge) override; |
||||
}; |
||||
|
||||
|
||||
// Creates a Slider Control - a grabbable handle that slides between two locations
|
||||
class Slider : public BaseControl |
||||
{ |
||||
public: |
||||
Slider(olc::QuickGUI::Manager& manager, // Associate with a Manager
|
||||
const olc::vf2d& posmin, // Screen location of "minimum"
|
||||
const olc::vf2d& posmax, // Screen location of "maximum"
|
||||
const float valmin, // Value of minimum
|
||||
const float valmax, // Value of maximum
|
||||
const float value); // Starting value
|
||||
|
||||
public: |
||||
// Minium value
|
||||
float fMin = -100.0f; |
||||
// Maximum value
|
||||
float fMax = +100.0f; |
||||
// Current value
|
||||
float fValue = 0.0f; |
||||
// Size of grab handle
|
||||
float fGrabRad = 8.0f; |
||||
// Location of minimum/start
|
||||
olc::vf2d vPosMin; |
||||
// Location of maximum/end
|
||||
olc::vf2d vPosMax; |
||||
|
||||
public: // BaseControl overrides
|
||||
void Update(olc::PixelGameEngine* pge) override; |
||||
void Draw(olc::PixelGameEngine* pge) override; |
||||
void DrawDecal(olc::PixelGameEngine* pge) override; |
||||
}; |
||||
|
||||
} |
||||
|
||||
|
||||
#ifdef OLC_PGEX_QUICKGUI |
||||
#undef OLC_PGEX_QUICKGUI |
||||
namespace olc::QuickGUI |
||||
{ |
||||
|
||||
#pragma region BaseControl |
||||
BaseControl::BaseControl(olc::QuickGUI::Manager& manager) : m_manager(manager) |
||||
{ |
||||
m_manager.AddControl(this); |
||||
} |
||||
|
||||
BaseControl::~BaseControl() |
||||
{ |
||||
|
||||
} |
||||
|
||||
void BaseControl::Enable(const bool bEnable) |
||||
{ |
||||
m_state = bEnable ? State::Normal : State::Disabled; |
||||
} |
||||
#pragma endregion |
||||
|
||||
#pragma region Manager |
||||
Manager::Manager(const bool bCleanUpForMe) |
||||
{ |
||||
m_bEraseControlsOnDestroy = bCleanUpForMe; |
||||
} |
||||
|
||||
Manager::~Manager() |
||||
{ |
||||
if (m_bEraseControlsOnDestroy) |
||||
for (auto& p : m_vControls) |
||||
delete p; |
||||
|
||||
m_vControls.clear(); |
||||
} |
||||
|
||||
void Manager::AddControl(BaseControl* control) |
||||
{ |
||||
m_vControls.push_back(control); |
||||
} |
||||
|
||||
void Manager::Update(olc::PixelGameEngine* pge) |
||||
{ |
||||
for (auto& p : m_vControls) p->Update(pge); |
||||
} |
||||
|
||||
void Manager::Draw(olc::PixelGameEngine* pge) |
||||
{ |
||||
for (auto& p : m_vControls) p->Draw(pge); |
||||
} |
||||
|
||||
void Manager::DrawDecal(olc::PixelGameEngine* pge) |
||||
{ |
||||
for (auto& p : m_vControls) p->DrawDecal(pge); |
||||
} |
||||
#pragma endregion |
||||
|
||||
#pragma region Label |
||||
Label::Label(olc::QuickGUI::Manager& manager, const std::string& text, const olc::vf2d& pos, const olc::vf2d& size) |
||||
: BaseControl(manager) |
||||
{ |
||||
vPos = pos; vSize = size; sText = text; |
||||
} |
||||
|
||||
void Label::Update(olc::PixelGameEngine* pge) |
||||
{ |
||||
|
||||
} |
||||
|
||||
void Label::Draw(olc::PixelGameEngine* pge) |
||||
{ |
||||
if (!bVisible) |
||||
return; |
||||
|
||||
if (bHasBackground) |
||||
{ |
||||
pge->FillRect(vPos + olc::vf2d(1, 1), vSize - olc::vf2d(2, 2), m_manager.colNormal); |
||||
} |
||||
|
||||
if(bHasBorder) |
||||
pge->DrawRect(vPos, vSize - olc::vf2d(1, 1), m_manager.colBorder); |
||||
|
||||
olc::vf2d vText = pge->GetTextSizeProp(sText); |
||||
switch (nAlign) |
||||
{ |
||||
case Alignment::Left: |
||||
pge->DrawStringProp(olc::vf2d( vPos.x + 2.0f, vPos.y + (vSize.y - vText.y) * 0.5f ), sText, m_manager.colText); |
||||
break; |
||||
case Alignment::Centre: |
||||
pge->DrawStringProp(vPos + (vSize - vText) * 0.5f, sText, m_manager.colText); |
||||
break; |
||||
case Alignment::Right: |
||||
pge->DrawStringProp(olc::vf2d{ vPos.x + vSize.x - vText.x - 2.0f, vPos.y + (vSize.y - vText.y) * 0.5f }, sText, m_manager.colText); |
||||
break; |
||||
} |
||||
} |
||||
|
||||
void Label::DrawDecal(olc::PixelGameEngine* pge) |
||||
{ |
||||
if (!bVisible) |
||||
return; |
||||
|
||||
if (bHasBackground) |
||||
{ |
||||
pge->FillRectDecal(vPos + olc::vf2d(1, 1), vSize - olc::vf2d(2, 2), m_manager.colNormal); |
||||
} |
||||
|
||||
if (bHasBorder) |
||||
{ |
||||
pge->SetDecalMode(olc::DecalMode::WIREFRAME); |
||||
pge->FillRectDecal(vPos + olc::vf2d(1, 1), vSize - olc::vf2d(2,2), m_manager.colBorder); |
||||
pge->SetDecalMode(olc::DecalMode::NORMAL); |
||||
} |
||||
|
||||
olc::vf2d vText = pge->GetTextSizeProp(sText); |
||||
switch (nAlign) |
||||
{ |
||||
case Alignment::Left: |
||||
pge->DrawStringPropDecal({ vPos.x + 2.0f, vPos.y + (vSize.y - vText.y) * 0.5f }, sText, m_manager.colText); |
||||
break; |
||||
case Alignment::Centre: |
||||
pge->DrawStringPropDecal(vPos + (vSize - vText) * 0.5f, sText, m_manager.colText); |
||||
break; |
||||
case Alignment::Right: |
||||
pge->DrawStringPropDecal({ vPos.x + vSize.x - vText.x - 2.0f, vPos.y + (vSize.y - vText.y) * 0.5f }, sText, m_manager.colText); |
||||
break; |
||||
} |
||||
} |
||||
#pragma endregion |
||||
|
||||
|
||||
#pragma region TextBox |
||||
TextBox::TextBox(olc::QuickGUI::Manager& manager, const std::string& text, const olc::vf2d& pos, const olc::vf2d& size) |
||||
: Label(manager, text, pos, size) |
||||
{ |
||||
nAlign = Alignment::Left; |
||||
bHasBorder = true; |
||||
bHasBackground = false; |
||||
} |
||||
|
||||
void TextBox::Update(olc::PixelGameEngine* pge) |
||||
{ |
||||
if (m_state == State::Disabled || !bVisible) |
||||
return; |
||||
|
||||
bPressed = false; |
||||
bReleased = false; |
||||
|
||||
olc::vf2d vMouse = pge->GetMousePos(); |
||||
|
||||
if (vMouse.x >= vPos.x && vMouse.x < vPos.x + vSize.x && |
||||
vMouse.y >= vPos.y && vMouse.y < vPos.y + vSize.y) |
||||
{ |
||||
// Released inside box does nothing to me, but i may have
|
||||
// to finish off the neighbours... oo err
|
||||
bReleased = pge->GetMouse(olc::Mouse::LEFT).bReleased; |
||||
if (bReleased && pge->IsTextEntryEnabled() && !m_bTextEdit) |
||||
{ |
||||
pge->TextEntryEnable(false); |
||||
} |
||||
|
||||
bPressed = pge->GetMouse(olc::Mouse::LEFT).bPressed; |
||||
if (bPressed && !pge->IsTextEntryEnabled() && !m_bTextEdit) |
||||
{
|
||||
pge->TextEntryEnable(true, sText); |
||||
m_bTextEdit = true; |
||||
} |
||||
|
||||
bHeld = pge->GetMouse(olc::Mouse::LEFT).bHeld; |
||||
|
||||
|
||||
} |
||||
else |
||||
{ |
||||
// Released outside box
|
||||
bReleased = pge->GetMouse(olc::Mouse::LEFT).bReleased; |
||||
if (bReleased && m_bTextEdit) |
||||
{ |
||||
sText = pge->TextEntryGetString(); |
||||
pge->TextEntryEnable(false); |
||||
m_bTextEdit = false; |
||||
} |
||||
}
|
||||
|
||||
if (m_bTextEdit && pge->IsTextEntryEnabled()) |
||||
sText = pge->TextEntryGetString(); |
||||
} |
||||
|
||||
void TextBox::Draw(olc::PixelGameEngine* pge) |
||||
{ |
||||
if (!bVisible) |
||||
return; |
||||
|
||||
if (bHasBackground) |
||||
{ |
||||
pge->FillRect(vPos + olc::vf2d(1, 1), vSize - olc::vf2d(2, 2), m_manager.colNormal); |
||||
} |
||||
|
||||
if (bHasBorder) |
||||
pge->DrawRect(vPos, vSize - olc::vf2d(1, 1), m_manager.colBorder); |
||||
|
||||
if (m_bTextEdit && pge->IsTextEntryEnabled()) |
||||
{ |
||||
// Draw Cursor
|
||||
int32_t i = pge->TextEntryGetCursor(); |
||||
olc::vf2d vCursorPos = pge->GetTextSizeProp(sText.substr(0, i)); |
||||
pge->FillRect(olc::vf2d(vPos.x + 2.0f + vCursorPos.x, (vPos.y + (vSize.y - 10.0f) * 0.5f)), { 2, 10 }, m_manager.colText); |
||||
} |
||||
|
||||
// Draw Text
|
||||
olc::vf2d vText = pge->GetTextSizeProp(sText); |
||||
pge->DrawStringProp(olc::vf2d(vPos.x + 2.0f, vPos.y + (vSize.y - vText.y) * 0.5f), sText, m_manager.colText); |
||||
|
||||
} |
||||
|
||||
void TextBox::DrawDecal(olc::PixelGameEngine* pge) |
||||
{ |
||||
if (!bVisible) |
||||
return; |
||||
|
||||
if (bHasBackground) |
||||
{ |
||||
pge->FillRectDecal(vPos + olc::vf2d(1, 1), vSize - olc::vf2d(2, 2), m_manager.colNormal); |
||||
} |
||||
|
||||
if (bHasBorder) |
||||
{ |
||||
pge->SetDecalMode(olc::DecalMode::WIREFRAME); |
||||
pge->FillRectDecal(vPos + olc::vf2d(1, 1), vSize - olc::vf2d(2, 2), m_manager.colBorder); |
||||
pge->SetDecalMode(olc::DecalMode::NORMAL); |
||||
} |
||||
|
||||
if (m_bTextEdit && pge->IsTextEntryEnabled()) |
||||
{ |
||||
// Draw Cursor
|
||||
int32_t i = pge->TextEntryGetCursor(); |
||||
olc::vf2d vCursorPos = pge->GetTextSizeProp(sText.substr(0, i)); |
||||
pge->FillRectDecal(olc::vf2d(vPos.x + 2.0f + vCursorPos.x, (vPos.y + (vSize.y - 10.0f) * 0.5f)), { 2, 10 }, m_manager.colText); |
||||
} |
||||
|
||||
// Draw Text
|
||||
olc::vf2d vText = pge->GetTextSizeProp(sText); |
||||
pge->DrawStringPropDecal(olc::vf2d(vPos.x + 2.0f, vPos.y + (vSize.y - vText.y) * 0.5f), sText, m_manager.colText); |
||||
} |
||||
#pragma endregion |
||||
|
||||
#pragma region Button |
||||
Button::Button(olc::QuickGUI::Manager& manager, const std::string& text, const olc::vf2d& pos, const olc::vf2d& size)
|
||||
: BaseControl(manager) |
||||
{ |
||||
vPos = pos; vSize = size; sText = text; |
||||
} |
||||
|
||||
void Button::Update(olc::PixelGameEngine* pge) |
||||
{ |
||||
if (m_state == State::Disabled || !bVisible) |
||||
return; |
||||
|
||||
bPressed = false; |
||||
bReleased = false; |
||||
float fElapsedTime = pge->GetElapsedTime(); |
||||
|
||||
olc::vf2d vMouse = pge->GetMousePos(); |
||||
if (m_state != State::Click) |
||||
{ |
||||
if (vMouse.x >= vPos.x && vMouse.x < vPos.x + vSize.x && |
||||
vMouse.y >= vPos.y && vMouse.y < vPos.y + vSize.y) |
||||
{ |
||||
m_fTransition += fElapsedTime * m_manager.fHoverSpeedOn; |
||||
m_state = State::Hover; |
||||
|
||||
bPressed = pge->GetMouse(olc::Mouse::LEFT).bPressed;
|
||||
if (bPressed) |
||||
{ |
||||
m_state = State::Click; |
||||
} |
||||
|
||||
bHeld = pge->GetMouse(olc::Mouse::LEFT).bHeld; |
||||
} |
||||
else |
||||
{ |
||||
m_fTransition -= fElapsedTime * m_manager.fHoverSpeedOff; |
||||
m_state = State::Normal; |
||||
} |
||||
} |
||||
else |
||||
{
|
||||
bHeld = pge->GetMouse(olc::Mouse::LEFT).bHeld; |
||||
bReleased = pge->GetMouse(olc::Mouse::LEFT).bReleased; |
||||
if (bReleased) m_state = State::Normal; |
||||
} |
||||
|
||||
m_fTransition = std::clamp(m_fTransition, 0.0f, 1.0f); |
||||
} |
||||
|
||||
void Button::Draw(olc::PixelGameEngine* pge) |
||||
{ |
||||
if (!bVisible) |
||||
return; |
||||
|
||||
switch (m_state) |
||||
{ |
||||
case State::Disabled: |
||||
pge->FillRect(vPos, vSize, m_manager.colDisable); |
||||
break; |
||||
case State::Normal: |
||||
case State::Hover: |
||||
pge->FillRect(vPos, vSize, olc::PixelLerp(m_manager.colNormal, m_manager.colHover, m_fTransition)); |
||||
break; |
||||
case State::Click: |
||||
pge->FillRect(vPos, vSize, m_manager.colClick); |
||||
break; |
||||
} |
||||
|
||||
pge->DrawRect(vPos, vSize - olc::vf2d(1, 1), m_manager.colBorder); |
||||
olc::vf2d vText = pge->GetTextSizeProp(sText); |
||||
pge->DrawStringProp(vPos + (vSize - vText) * 0.5f, sText, m_manager.colText); |
||||
} |
||||
|
||||
void Button::DrawDecal(olc::PixelGameEngine* pge) |
||||
{ |
||||
if (!bVisible) |
||||
return; |
||||
|
||||
switch (m_state) |
||||
{ |
||||
case State::Disabled: |
||||
pge->FillRectDecal(vPos + olc::vf2d(1, 1), vSize - olc::vf2d(2, 2), m_manager.colDisable); |
||||
break; |
||||
case State::Normal: |
||||
case State::Hover: |
||||
pge->FillRectDecal(vPos + olc::vf2d(1, 1), vSize - olc::vf2d(2, 2), olc::PixelLerp(m_manager.colNormal, m_manager.colHover, m_fTransition)); |
||||
break; |
||||
case State::Click: |
||||
pge->FillRectDecal(vPos + olc::vf2d(1, 1), vSize - olc::vf2d(2, 2), m_manager.colClick); |
||||
break; |
||||
} |
||||
pge->SetDecalMode(olc::DecalMode::WIREFRAME); |
||||
pge->FillRectDecal(vPos + olc::vf2d(1, 1), vSize - olc::vf2d(2, 2), m_manager.colBorder); |
||||
pge->SetDecalMode(olc::DecalMode::NORMAL); |
||||
|
||||
olc::vf2d vText = pge->GetTextSizeProp(sText); |
||||
pge->DrawStringPropDecal(vPos + (vSize - vText) * 0.5f, sText, m_manager.colText); |
||||
} |
||||
#pragma endregion |
||||
|
||||
|
||||
#pragma region CheckBox |
||||
CheckBox::CheckBox(olc::QuickGUI::Manager& manager, const std::string& text, const bool check, const olc::vf2d& pos, const olc::vf2d& size) |
||||
: Button(manager, text, pos, size) |
||||
{ |
||||
bChecked = check; |
||||
} |
||||
|
||||
void CheckBox::Update(olc::PixelGameEngine* pge) |
||||
{ |
||||
if (m_state == State::Disabled || !bVisible) |
||||
return; |
||||
|
||||
Button::Update(pge); |
||||
if (bPressed) bChecked = !bChecked; |
||||
} |
||||
|
||||
void CheckBox::Draw(olc::PixelGameEngine* pge) |
||||
{ |
||||
if (!bVisible) |
||||
return; |
||||
|
||||
Button::Draw(pge); |
||||
|
||||
if (bChecked) |
||||
pge->DrawRect(vPos + olc::vf2d(2, 2), vSize - olc::vi2d(4, 4), m_manager.colBorder); |
||||
} |
||||
|
||||
void CheckBox::DrawDecal(olc::PixelGameEngine* pge) |
||||
{ |
||||
if (!bVisible) |
||||
return; |
||||
|
||||
Button::DrawDecal(pge); |
||||
|
||||
pge->SetDecalMode(olc::DecalMode::WIREFRAME); |
||||
pge->FillRectDecal(vPos + olc::vf2d(2,2), vSize - olc::vf2d(4, 4), m_manager.colBorder); |
||||
pge->SetDecalMode(olc::DecalMode::NORMAL); |
||||
|
||||
olc::vf2d vText = pge->GetTextSizeProp(sText); |
||||
pge->DrawStringPropDecal(vPos + (vSize - vText) * 0.5f, sText, m_manager.colText); |
||||
} |
||||
#pragma endregion |
||||
|
||||
#pragma region Slider |
||||
Slider::Slider(olc::QuickGUI::Manager& manager, const olc::vf2d& posmin, const olc::vf2d& posmax, const float valmin, const float valmax, const float value)
|
||||
: BaseControl(manager) |
||||
{ |
||||
vPosMin = posmin; vPosMax = posmax; fMin = valmin; fMax = valmax; fValue = value; |
||||
} |
||||
|
||||
void Slider::Update(olc::PixelGameEngine* pge) |
||||
{ |
||||
if (m_state == State::Disabled || !bVisible) |
||||
return; |
||||
|
||||
float fElapsedTime = pge->GetElapsedTime(); |
||||
|
||||
olc::vf2d vMouse = pge->GetMousePos(); |
||||
bHeld = false; |
||||
if (m_state == State::Click) |
||||
{ |
||||
olc::vf2d d = vPosMax - vPosMin; |
||||
float u = d.dot(vMouse - vPosMin) / d.mag2(); |
||||
fValue = u * (fMax - fMin) + fMin; |
||||
bHeld = true; |
||||
} |
||||
else |
||||
{ |
||||
olc::vf2d vSliderPos = vPosMin + (vPosMax - vPosMin) * ((fValue - fMin) / (fMax - fMin)); |
||||
if ((vMouse - vSliderPos).mag2() <= int32_t(fGrabRad) * int32_t(fGrabRad)) |
||||
{ |
||||
m_fTransition += fElapsedTime * m_manager.fHoverSpeedOn; |
||||
m_state = State::Hover; |
||||
if (pge->GetMouse(olc::Mouse::LEFT).bPressed) |
||||
{ |
||||
m_state = State::Click; |
||||
bPressed = true; |
||||
} |
||||
} |
||||
else |
||||
m_state = State::Normal; |
||||
} |
||||
|
||||
if (pge->GetMouse(olc::Mouse::LEFT).bReleased) |
||||
{ |
||||
m_state = State::Normal; |
||||
bReleased = true; |
||||
} |
||||
|
||||
if (m_state == State::Normal) |
||||
{ |
||||
m_fTransition -= fElapsedTime * m_manager.fHoverSpeedOff; |
||||
m_state = State::Normal; |
||||
bHeld = false;
|
||||
} |
||||
|
||||
fValue = std::clamp(fValue, fMin, fMax); |
||||
m_fTransition = std::clamp(m_fTransition, 0.0f, 1.0f); |
||||
} |
||||
|
||||
void Slider::Draw(olc::PixelGameEngine* pge) |
||||
{ |
||||
if (!bVisible) |
||||
return; |
||||
|
||||
pge->DrawLine(vPosMin, vPosMax, m_manager.colBorder); |
||||
olc::vf2d vSliderPos = vPosMin + (vPosMax - vPosMin) * ((fValue - fMin) / (fMax - fMin)); |
||||
|
||||
switch (m_state) |
||||
{ |
||||
case State::Disabled: |
||||
pge->FillCircle(vSliderPos, int32_t(fGrabRad), m_manager.colDisable); |
||||
break; |
||||
case State::Normal: |
||||
case State::Hover: |
||||
pge->FillCircle(vSliderPos, int32_t(fGrabRad), olc::PixelLerp(m_manager.colNormal, m_manager.colHover, m_fTransition)); |
||||
break; |
||||
case State::Click: |
||||
pge->FillCircle(vSliderPos, int32_t(fGrabRad), m_manager.colClick); |
||||
break; |
||||
} |
||||
|
||||
|
||||
pge->DrawCircle(vSliderPos, int32_t(fGrabRad), m_manager.colBorder); |
||||
} |
||||
|
||||
void Slider::DrawDecal(olc::PixelGameEngine* pge) |
||||
{ |
||||
if (!bVisible) |
||||
return; |
||||
|
||||
pge->DrawLineDecal(vPosMin, vPosMax, m_manager.colBorder); |
||||
olc::vf2d vSliderPos = vPosMin + (vPosMax - vPosMin) * ((fValue - fMin) / (fMax - fMin)); |
||||
|
||||
switch (m_state) |
||||
{ |
||||
case State::Disabled: |
||||
pge->FillRectDecal(vSliderPos - olc::vf2d(fGrabRad, fGrabRad), olc::vf2d(fGrabRad, fGrabRad) * 2.0f, m_manager.colDisable); |
||||
break; |
||||
case State::Normal: |
||||
case State::Hover: |
||||
pge->FillRectDecal(vSliderPos - olc::vf2d(fGrabRad, fGrabRad), olc::vf2d(fGrabRad, fGrabRad) * 2.0f, olc::PixelLerp(m_manager.colNormal, m_manager.colHover, m_fTransition)); |
||||
break; |
||||
case State::Click: |
||||
pge->FillRectDecal(vSliderPos - olc::vf2d(fGrabRad, fGrabRad), olc::vf2d(fGrabRad, fGrabRad) * 2.0f, m_manager.colClick); |
||||
break; |
||||
} |
||||
|
||||
pge->SetDecalMode(olc::DecalMode::WIREFRAME); |
||||
pge->FillRectDecal(vSliderPos - olc::vf2d(fGrabRad, fGrabRad), olc::vf2d(fGrabRad, fGrabRad) * 2.0f, m_manager.colBorder); |
||||
pge->SetDecalMode(olc::DecalMode::NORMAL); |
||||
} |
||||
|
||||
|
||||
#pragma endregion |
||||
|
||||
} |
||||
#endif // OLC_PGEX_QUICKGUI
|
||||
#endif // OLC_PGEX_QUICKGUI_H
|
@ -0,0 +1,9 @@ |
||||
export AUTO_UPDATE=true |
||||
|
||||
source utils/define.sh |
||||
|
||||
define PROJECT_NAME "C++ProjectTemplate" |
||||
define CUSTOM_PARAMS "-std=c++17 -lX11 -lGL -lpthread -lpng -lstdc++fs -lpulse -lpulse-simple -I/usr/include/lua5.3" |
||||
define LANGUAGE "C++" |
||||
|
||||
source utils/main.sh |
@ -0,0 +1,53 @@ |
||||
// The MIT License (MIT)
|
||||
|
||||
// Copyright (c) 2013-2020 Rapptz, ThePhD and contributors
|
||||
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
// this software and associated documentation files (the "Software"), to deal in
|
||||
// the Software without restriction, including without limitation the rights to
|
||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
// the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
// subject to the following conditions:
|
||||
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// This file was generated with a script.
|
||||
// Generated 2022-06-25 08:14:19.336233 UTC
|
||||
// This header was generated with sol v3.3.0 (revision eba86625)
|
||||
// https://github.com/ThePhD/sol2
|
||||
|
||||
#ifndef SOL_SINGLE_CONFIG_HPP |
||||
#define SOL_SINGLE_CONFIG_HPP |
||||
|
||||
// beginning of sol/config.hpp
|
||||
|
||||
/* Base, empty configuration file!
|
||||
|
||||
To override, place a file in your include paths of the form: |
||||
|
||||
. (your include path here) |
||||
| sol (directory, or equivalent) |
||||
| config.hpp (your config.hpp file) |
||||
|
||||
So that when sol2 includes the file |
||||
|
||||
#include <sol/config.hpp> |
||||
|
||||
it gives you the configuration values you desire. Configuration values can be |
||||
seen in the safety.rst of the doc/src, or at |
||||
https://sol2.readthedocs.io/en/latest/safety.html ! You can also pass them through
|
||||
the build system, or the command line options of your compiler. |
||||
|
||||
*/ |
||||
|
||||
// end of sol/config.hpp
|
||||
|
||||
#endif // SOL_SINGLE_CONFIG_HPP
|
@ -0,0 +1 @@ |
||||
sigonasr2 <sigonasr2@gmail.com> |
@ -0,0 +1,5 @@ |
||||
Java/ |
||||
C/ |
||||
C++/ |
||||
scripts/ |
||||
utils/ |
@ -0,0 +1,26 @@ |
||||
export VARS=("") |
||||
|
||||
export LANGUAGE="" |
||||
|
||||
function define() { |
||||
VARS+=("$1") |
||||
value="${*:2}" |
||||
eval export "$1"='$value' |
||||
} |
||||
|
||||
if [[ $(pwd) != *"SigScript" && $AUTO_UPDATE = "true" && $1 != "update" ]]; then |
||||
source utils/search.sh |
||||
|
||||
find . -type f -name md5 -delete |
||||
find . -type f -name filelist -delete |
||||
|
||||
#Check for hashes |
||||
FILES=$(cat utils/.updateDirectories) |
||||
for f in $FILES |
||||
do |
||||
search $f |
||||
check $f |
||||
done |
||||
else |
||||
echo "Dev build, no checks required." |
||||
fi |
@ -0,0 +1,5 @@ |
||||
.coauthors |
||||
define.sh |
||||
main.sh |
||||
search.sh |
||||
.updateDirectories |
@ -0,0 +1,28 @@ |
||||
if [ -z "$1" ] |
||||
then |
||||
echo "" |
||||
echo " Usage: ./sig <command> {args}" |
||||
echo "" |
||||
printf "====\tCurrent Configuration" |
||||
printf "\t=====================" |
||||
for t in ${VARS[@]} |
||||
do |
||||
printf "\n\t%-15s%20s" $t ${!t} |
||||
done |
||||
printf "\n=====================================================" |
||||
echo "" |
||||
echo "" |
||||
echo " Command List:" |
||||
FILES=$(ls -1A ./$LANGUAGE/scripts 2>/dev/null | sed -e 's/\.sh$//' | sed -e 's/^/ /') |
||||
for f in $FILES |
||||
do |
||||
if [ -f "./$LANGUAGE/scripts/$f.sh" ]; then |
||||
DESC="$(head -n1 ./$LANGUAGE/scripts/$f.sh)" |
||||
printf "\n\t%-15s%-65s" $f "${DESC:1}" |
||||
fi |
||||
done |
||||
echo "" |
||||
exit |
||||
fi |
||||
|
||||
./$LANGUAGE/scripts/$1.sh "${@:2}" |
@ -0,0 +1,4 @@ |
||||
define.sh:3ecab0dffe2adfb950f3eb7c7061b750 - |
||||
main.sh:4e6e9f0650ec790ce2c4364db94f0caa - |
||||
search.sh:30e1842e9a13452ea883bb6516d28e1c - |
||||
.updateDirectories:971afb892e8280cb4c9ad43fb72a46a0 - |
@ -0,0 +1,103 @@ |
||||
function search() { |
||||
FILES2=$(ls -A $1 2>/dev/null) |
||||
for g in $FILES2 |
||||
do |
||||
if [ -d $1$g ]; |
||||
then |
||||
echo "$1$g is a directory" |
||||
search $1$g/ |
||||
else |
||||
echo "$1$g is a file" |
||||
if [ $g != "md5" ] && [ $g != "filelist" ] && [ $g != ".package.files" ]; then |
||||
if [ $g != ".coauthors" ] && [ $g != "version_info" ]; then |
||||
SUM=$(md5sum < $1$g) |
||||
echo "$g:$SUM" >> $1md5 |
||||
fi |
||||
echo "$g" >> $1filelist |
||||
else |
||||
echo " ignoring $g..." |
||||
fi |
||||
fi |
||||
done |
||||
} |
||||
|
||||
function check() { |
||||
echo "Check $1" |
||||
FILES2=$(ls -A $1 2>/dev/null) |
||||
if [ -f "$1/md5" ]; |
||||
then |
||||
echo " md5: http://sig.projectdivar.com/sigonasr2/SigScript/raw/branch/main/$1md5" |
||||
curl -H 'Cache-Control: no-cache, no-store' -s "http://sig.projectdivar.com/sigonasr2/SigScript/raw/branch/main/$1md5" --output /tmp/out |
||||
cmp -s $1/md5 /tmp/out |
||||
if [ "$?" -ne 0 ] |
||||
then |
||||
echo " Differences detected!" |
||||
cat /tmp/out |
||||
while IFS= read -r line |
||||
do |
||||
IFS=':' read -ra split <<< $line |
||||
g="${split[0]}" |
||||
echo "LINE -- $g" |
||||
if [ "$g" != "md5" ] && [ "$g" != "filelist" ] && [ "$g" != ".package.files" ]; then |
||||
if [ -f $1$g ]; |
||||
then |
||||
if [ "$g" != ".coauthors" ] && [ "$g" != "version_info" ]; then |
||||
echo "++Redownload $1$g..." |
||||
if [ -f "$1$g" ]; then |
||||
curl -H 'Cache-Control: no-cache, no-store' "http://sig.projectdivar.com/sigonasr2/SigScript/raw/branch/main/$1$g" --output $1$g |
||||
else |
||||
echo "===Could not find directory, assuming regular scripts directory exists." |
||||
curl -H 'Cache-Control: no-cache, no-store' "http://sig.projectdivar.com/sigonasr2/SigScript/raw/branch/main/$1$g" --output $LANGUAGE/scripts/$g |
||||
fi |
||||
fi |
||||
else |
||||
echo "++==Downloading $1$g..." |
||||
curl -H 'Cache-Control: no-cache, no-store' "http://sig.projectdivar.com/sigonasr2/SigScript/raw/branch/main/$1$g" --output $1$g |
||||
fi |
||||
fi |
||||
done < /tmp/out |
||||
fi |
||||
fi |
||||
if [ -f "$1/filelist" ]; |
||||
then |
||||
echo " filelist: http://sig.projectdivar.com/sigonasr2/SigScript/raw/branch/main/$1filelist" |
||||
curl -H 'Cache-Control: no-cache, no-store' -s "http://sig.projectdivar.com/sigonasr2/SigScript/raw/branch/main/$1filelist" --output /tmp/out |
||||
cmp -s $1/filelist /tmp/out |
||||
if [ "$?" -ne 0 ] |
||||
then |
||||
echo " Differences detected!" |
||||
cat /tmp/out |
||||
while IFS= read -r line |
||||
do |
||||
IFS=':' read -ra split <<< $line |
||||
g="${split[0]}" |
||||
echo "LINE -- $g" |
||||
if [ "$g" != "md5" ] && [ "$g" != "filelist" ] && [ "$g" != ".package.files" ]; then |
||||
if [ -f $1$g ]; |
||||
then |
||||
if [ "$g" != ".coauthors" ] && [ "$g" != "version_info" ]; then |
||||
echo "++Redownload $1$g..." |
||||
if [ -f "$1$g" ]; then |
||||
curl -H 'Cache-Control: no-cache, no-store' "http://sig.projectdivar.com/sigonasr2/SigScript/raw/branch/main/$1$g" --output $1$g |
||||
else |
||||
echo "===Could not find directory, assuming regular scripts directory exists." |
||||
curl -H 'Cache-Control: no-cache, no-store' "http://sig.projectdivar.com/sigonasr2/SigScript/raw/branch/main/$1$g" --output $LANGUAGE/scripts/$g |
||||
fi |
||||
fi |
||||
else |
||||
echo "++==Downloading $1$g..." |
||||
curl -H 'Cache-Control: no-cache, no-store' "http://sig.projectdivar.com/sigonasr2/SigScript/raw/branch/main/$1$g" --output $1$g |
||||
fi |
||||
fi |
||||
done < /tmp/out |
||||
fi |
||||
fi |
||||
for g in $FILES2 |
||||
do |
||||
if [ -d $1$g ]; |
||||
then |
||||
echo "$1$g is a directory" |
||||
check $1$g/ |
||||
fi |
||||
done |
||||
} |