mirror of
https://github.com/sigonasr2/Shep.git
synced 2025-09-01 19:38:42 -05:00
Add Dialog system, add in input controls. Add in windowing/theme system. Add in gradient rectangle outlines.
This commit is contained in:
parent
07e71a5975
commit
285cc89b04
54
Makefile
54
Makefile
@ -141,6 +141,30 @@ copy_data/fast:
|
||||
$(MAKE) $(MAKESILENT) -f CMakeFiles\copy_data.dir\build.make CMakeFiles/copy_data.dir/build
|
||||
.PHONY : copy_data/fast
|
||||
|
||||
src/Dialog.o: src/Dialog.cpp.o
|
||||
.PHONY : src/Dialog.o
|
||||
|
||||
# target to build an object file
|
||||
src/Dialog.cpp.o:
|
||||
$(MAKE) $(MAKESILENT) -f CMakeFiles\Shep.dir\build.make CMakeFiles/Shep.dir/src/Dialog.cpp.o
|
||||
.PHONY : src/Dialog.cpp.o
|
||||
|
||||
src/Dialog.i: src/Dialog.cpp.i
|
||||
.PHONY : src/Dialog.i
|
||||
|
||||
# target to preprocess a source file
|
||||
src/Dialog.cpp.i:
|
||||
$(MAKE) $(MAKESILENT) -f CMakeFiles\Shep.dir\build.make CMakeFiles/Shep.dir/src/Dialog.cpp.i
|
||||
.PHONY : src/Dialog.cpp.i
|
||||
|
||||
src/Dialog.s: src/Dialog.cpp.s
|
||||
.PHONY : src/Dialog.s
|
||||
|
||||
# target to generate assembly for a file
|
||||
src/Dialog.cpp.s:
|
||||
$(MAKE) $(MAKESILENT) -f CMakeFiles\Shep.dir\build.make CMakeFiles/Shep.dir/src/Dialog.cpp.s
|
||||
.PHONY : src/Dialog.cpp.s
|
||||
|
||||
src/GameObject.o: src/GameObject.cpp.o
|
||||
.PHONY : src/GameObject.o
|
||||
|
||||
@ -237,6 +261,30 @@ src/Theme.cpp.s:
|
||||
$(MAKE) $(MAKESILENT) -f CMakeFiles\Shep.dir\build.make CMakeFiles/Shep.dir/src/Theme.cpp.s
|
||||
.PHONY : src/Theme.cpp.s
|
||||
|
||||
src/Trigger.o: src/Trigger.cpp.o
|
||||
.PHONY : src/Trigger.o
|
||||
|
||||
# target to build an object file
|
||||
src/Trigger.cpp.o:
|
||||
$(MAKE) $(MAKESILENT) -f CMakeFiles\Shep.dir\build.make CMakeFiles/Shep.dir/src/Trigger.cpp.o
|
||||
.PHONY : src/Trigger.cpp.o
|
||||
|
||||
src/Trigger.i: src/Trigger.cpp.i
|
||||
.PHONY : src/Trigger.i
|
||||
|
||||
# target to preprocess a source file
|
||||
src/Trigger.cpp.i:
|
||||
$(MAKE) $(MAKESILENT) -f CMakeFiles\Shep.dir\build.make CMakeFiles/Shep.dir/src/Trigger.cpp.i
|
||||
.PHONY : src/Trigger.cpp.i
|
||||
|
||||
src/Trigger.s: src/Trigger.cpp.s
|
||||
.PHONY : src/Trigger.s
|
||||
|
||||
# target to generate assembly for a file
|
||||
src/Trigger.cpp.s:
|
||||
$(MAKE) $(MAKESILENT) -f CMakeFiles\Shep.dir\build.make CMakeFiles/Shep.dir/src/Trigger.cpp.s
|
||||
.PHONY : src/Trigger.cpp.s
|
||||
|
||||
src/olcPGEX_MiniAudio.o: src/olcPGEX_MiniAudio.cpp.o
|
||||
.PHONY : src/olcPGEX_MiniAudio.o
|
||||
|
||||
@ -319,6 +367,9 @@ help:
|
||||
@echo ... rebuild_cache
|
||||
@echo ... copy_data
|
||||
@echo ... Shep
|
||||
@echo ... src/Dialog.o
|
||||
@echo ... src/Dialog.i
|
||||
@echo ... src/Dialog.s
|
||||
@echo ... src/GameObject.o
|
||||
@echo ... src/GameObject.i
|
||||
@echo ... src/GameObject.s
|
||||
@ -331,6 +382,9 @@ help:
|
||||
@echo ... src/Theme.o
|
||||
@echo ... src/Theme.i
|
||||
@echo ... src/Theme.s
|
||||
@echo ... src/Trigger.o
|
||||
@echo ... src/Trigger.i
|
||||
@echo ... src/Trigger.s
|
||||
@echo ... src/olcPGEX_MiniAudio.o
|
||||
@echo ... src/olcPGEX_MiniAudio.i
|
||||
@echo ... src/olcPGEX_MiniAudio.s
|
||||
|
@ -3,7 +3,7 @@
|
||||
"height": 4300,
|
||||
"width": 2
|
||||
},
|
||||
"activeFile": "",
|
||||
"activeFile": "bin/assets/maps/Town1.tmx",
|
||||
"expandedProjectPaths": [
|
||||
],
|
||||
"fileStates": {
|
||||
@ -11,7 +11,16 @@
|
||||
"scaleInDock": 1,
|
||||
"scaleInEditor": 1
|
||||
},
|
||||
"bin/assets/maps/Town1.tmx": {
|
||||
"scale": 1.5,
|
||||
"selectedLayer": 2,
|
||||
"viewCenter": {
|
||||
"x": 80.66666666666669,
|
||||
"y": 102
|
||||
}
|
||||
},
|
||||
"bin/assets/maps/Village.tsx": {
|
||||
"scaleInDock": 2,
|
||||
"scaleInEditor": 3
|
||||
}
|
||||
},
|
||||
@ -20,10 +29,12 @@
|
||||
"map.fixedSize": false,
|
||||
"map.lastUsedFormat": "tmx",
|
||||
"openFiles": [
|
||||
"bin/assets/maps/Town1.tmx"
|
||||
],
|
||||
"project": "Shep.tiled-project",
|
||||
"property.type": "Buildings",
|
||||
"recentFiles": [
|
||||
"bin/assets/maps/Town1.tmx",
|
||||
"bin/assets/maps/Village.tsx",
|
||||
"bin/assets/maps/Collision.tsx"
|
||||
],
|
||||
|
16
Shep.vcxproj
16
Shep.vcxproj
@ -345,6 +345,10 @@ if %errorlevel% neq 0 goto :VCEnd</Command>
|
||||
</CustomBuild>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\Dialog.cpp">
|
||||
<SubType>
|
||||
</SubType>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\GameObject.cpp">
|
||||
<SubType>
|
||||
</SubType>
|
||||
@ -360,6 +364,10 @@ if %errorlevel% neq 0 goto :VCEnd</Command>
|
||||
<SubType>
|
||||
</SubType>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Trigger.cpp">
|
||||
<SubType>
|
||||
</SubType>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\util.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@ -367,6 +375,10 @@ if %errorlevel% neq 0 goto :VCEnd</Command>
|
||||
<SubType>
|
||||
</SubType>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\Dialog.h">
|
||||
<SubType>
|
||||
</SubType>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\GameObject.h">
|
||||
<SubType>
|
||||
</SubType>
|
||||
@ -408,6 +420,10 @@ if %errorlevel% neq 0 goto :VCEnd</Command>
|
||||
<SubType>
|
||||
</SubType>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\Trigger.h">
|
||||
<SubType>
|
||||
</SubType>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\util.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
|
@ -33,6 +33,12 @@
|
||||
<ClCompile Include="src\Theme.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Trigger.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Dialog.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="src\miniaudio.h">
|
||||
@ -83,5 +89,11 @@
|
||||
<ClInclude Include="src\Theme.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\Trigger.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\Dialog.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
Binary file not shown.
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 6.5 KiB |
@ -86,7 +86,7 @@
|
||||
0,0,0,1025,1025,1025,1025,1025,1025,1025,1025,1025,1025,1025,1025,1025,1025,1025,1025,1025,1025,1025,1025,1025,1025,0,0,0,0,0,0,0,0,0,0
|
||||
</data>
|
||||
</layer>
|
||||
<objectgroup id="4" name="Object Layer 1" visible="0">
|
||||
<objectgroup id="4" name="Object Layer 1">
|
||||
<object id="1" type="Building" x="64" y="48" width="128" height="96">
|
||||
<properties>
|
||||
<property name="Building Type" propertytype="Buildings" value="building1"/>
|
||||
|
88
src/Dialog.cpp
Normal file
88
src/Dialog.cpp
Normal file
@ -0,0 +1,88 @@
|
||||
#pragma region License
|
||||
/*
|
||||
License (OLC-3)
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
Copyright 2024 Joshua Sigona <sigonasr2@gmail.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.
|
||||
|
||||
Portions of this software are copyright © 2024 The FreeType
|
||||
Project (www.freetype.org). Please see LICENSE_FT.txt for more information.
|
||||
All rights reserved.
|
||||
*/
|
||||
#pragma endregion
|
||||
|
||||
#include "olcUTIL_Geometry2D.h"
|
||||
#include "Dialog.h"
|
||||
#include "Theme.h"
|
||||
#include "ShepGame.h"
|
||||
#include <ranges>
|
||||
|
||||
Dialog Dialog::instance;
|
||||
|
||||
Dialog::Dialog():Trigger({}){};
|
||||
|
||||
void Dialog::Create(const std::string_view text,const std::function<void()>onComplete){
|
||||
instance.isActive=true;
|
||||
instance.text=std::string(text);
|
||||
instance.cursor=0;
|
||||
instance.waitForReleaseKey=true;
|
||||
instance.Trigger::Trigger([onComplete](){instance.isActive=false;if(onComplete)onComplete();});
|
||||
}
|
||||
void Dialog::UpdateAndDraw(){
|
||||
auto&game{ShepGame::Game()};
|
||||
const bool CursorAtEnd=instance.cursor==instance.text.length();
|
||||
if(CursorAtEnd&&!instance.waitForReleaseKey&&game.GetInputPressed(GameSettings::CONFIRM_DIALOG))instance.trigger();
|
||||
|
||||
if(instance.waitForReleaseKey&&!game.GetInput(GameSettings::CONFIRM_DIALOG))instance.waitForReleaseKey=false;
|
||||
if(!CursorAtEnd&&!instance.waitForReleaseKey&&game.GetInputPressed(GameSettings::CONFIRM_DIALOG)){
|
||||
instance.cursor=instance.text.length();
|
||||
instance.waitForReleaseKey=true;
|
||||
}
|
||||
|
||||
instance.frameTime-=game.GetElapsedTime();
|
||||
if(instance.frameTime<=0.f){
|
||||
instance.frameTime=GameSettings::FRAME_TIME_PER_CHAR;
|
||||
instance.cursor=std::min(instance.text.length(),size_t(instance.cursor+1));
|
||||
}
|
||||
|
||||
const vi2d WINDOW_UPPER_LEFT{int(game.GetScreenSize().x*1/6.f),int(game.GetScreenSize().y-192-16)};
|
||||
const vi2d WINDOW_SIZE{int(game.GetScreenSize().x*2/3.f),192};
|
||||
const geom2d::rect<int>WINDOW{WINDOW_UPPER_LEFT,WINDOW_SIZE};
|
||||
Theme::DrawWindow(WINDOW);
|
||||
std::string displayText{GetText()};
|
||||
game.DrawStringPropDecal(WINDOW_UPPER_LEFT+vi2d{8,0},displayText,WHITE,{4.f,4.f});
|
||||
}
|
||||
const bool Dialog::Exists(){
|
||||
return instance.isActive;
|
||||
}
|
||||
const std::string Dialog::GetText(){
|
||||
return instance.text.substr(0,instance.cursor);
|
||||
}
|
||||
const void Dialog::AdvanceToEnd(){
|
||||
instance.cursor=instance.text.length();
|
||||
}
|
61
src/Dialog.h
Normal file
61
src/Dialog.h
Normal file
@ -0,0 +1,61 @@
|
||||
#pragma region License
|
||||
/*
|
||||
License (OLC-3)
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
Copyright 2024 Joshua Sigona <sigonasr2@gmail.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.
|
||||
|
||||
Portions of this software are copyright © 2024 The FreeType
|
||||
Project (www.freetype.org). Please see LICENSE_FT.txt for more information.
|
||||
All rights reserved.
|
||||
*/
|
||||
#pragma endregion
|
||||
#pragma once
|
||||
|
||||
#include "Trigger.h"
|
||||
#include <string_view>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include "GameSettings.h"
|
||||
|
||||
class Dialog:public Trigger{
|
||||
public:
|
||||
static void Create(const std::string_view text,const std::function<void()>onComplete={});
|
||||
static const bool Exists(); //If a dialog exists, use this function to trap other game inputs from occurring.
|
||||
static const std::string GetText();
|
||||
static const void AdvanceToEnd();
|
||||
static void UpdateAndDraw();
|
||||
private:
|
||||
Dialog();
|
||||
static Dialog instance;
|
||||
std::string text;
|
||||
uint32_t cursor{};
|
||||
float frameTime{GameSettings::FRAME_TIME_PER_CHAR};
|
||||
bool isActive{false};
|
||||
bool waitForReleaseKey{true};
|
||||
};
|
@ -38,6 +38,9 @@ All rights reserved.
|
||||
#pragma once
|
||||
|
||||
#include "olcUTIL_Hardware3D.h"
|
||||
#include "olcPixelGameEngine.h"
|
||||
|
||||
using Action=std::vector<Key>;
|
||||
|
||||
class GameSettings{
|
||||
public:
|
||||
@ -47,4 +50,21 @@ public:
|
||||
inline static constexpr float PLAYER_SPD{5.f};
|
||||
inline static vf3d CAMERA_FOLLOW_POS{0,-3.77,-3.2};
|
||||
inline static float CAMERA_TILT{51.35};
|
||||
|
||||
inline static float FRAME_TIME_PER_CHAR{1/30.f};
|
||||
inline static Action CONFIRM_DIALOG{{Key::ENTER,Key::SPACE,Key::Z,Key::SHIFT,Key::RETURN}};
|
||||
|
||||
#define S inline static std::string_view
|
||||
class Text{
|
||||
S INTRO{"Welcome! You are about to begin a great journey of your own."};
|
||||
S INTRO_2{"This land is inhabited by creatures called Shep! "
|
||||
"Where they come from and their mysteries have yet to be discovered. Why are they here?"};
|
||||
S INTRO_3{"Speaking of, what is your name?"};
|
||||
S INTRO_4{"Your adventure is about to unfold, come by my lab when you are ready! I will see you there."};
|
||||
S MOM_INTRO{"Oh {}! I know today is the big day, before you go I want to give you this!"};
|
||||
S MOM_SHAPEDIA{"It's a Shapedia! As you explore it will keep track of your findings. I'm sure it will come in handy!"};
|
||||
S MOM_OUTFIT{"Also are you sure you want to be in that outfit? It's a bit tacky..."};
|
||||
S MOM_OUTFIT2{"Oh, you like your knight outfit that much don't you? I understand. Have fun today {}!"};
|
||||
};
|
||||
#undef S
|
||||
};
|
@ -3,6 +3,7 @@
|
||||
#include "TMXParser.h"
|
||||
#include "Theme.h"
|
||||
#include <ranges>
|
||||
#include "Dialog.h"
|
||||
|
||||
ShepGame*ShepGame::game{nullptr};
|
||||
|
||||
@ -259,11 +260,32 @@ bool ShepGame::OnUserUpdate(float fElapsedTime){
|
||||
HW3D_DrawObject((matView*matWorld).m,nullptr,meshSpr.layout,meshSpr.pos,meshSpr.uv,lightCol);
|
||||
}
|
||||
}
|
||||
|
||||
Theme::DrawWindow({{20,20},{40,40}});
|
||||
if(GetInputPressed(GameSettings::CONFIRM_DIALOG)&&!Dialog::Exists())
|
||||
Dialog::Create("Hello World!\nThis is a test\nof three lines",
|
||||
[](){
|
||||
Dialog::Create("This is a second message!",{});});
|
||||
if(Dialog::Exists())Dialog::UpdateAndDraw();
|
||||
|
||||
return true;
|
||||
}
|
||||
const bool ShepGame::GetInput(const Action&action){
|
||||
for(const Key&a:action|std::views::filter([this](const Key&key){return GetKey(key).bHeld;})){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
const bool ShepGame::GetInputPressed(const Action&action){
|
||||
for(const Key&a:action|std::views::filter([this](const Key&key){return GetKey(key).bPressed;})){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
const bool ShepGame::GetInputReleased(const Action&action){
|
||||
for(const Key&a:action|std::views::filter([this](const Key&key){return GetKey(key).bReleased;})){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
ShepGame&ShepGame::Game(){
|
||||
if(game==nullptr){
|
||||
|
@ -43,6 +43,7 @@ All rights reserved.
|
||||
#include "util.h"
|
||||
#include "Light.h"
|
||||
#include "GameObject.h"
|
||||
#include "GameSettings.h"
|
||||
#include <set>
|
||||
|
||||
class ShepGame : public olc::PixelGameEngine
|
||||
@ -58,6 +59,10 @@ public:
|
||||
static ShepGame&Game();
|
||||
void LoadMap(const std::string&filename);
|
||||
std::unordered_map<AnimationState,Animate2D::FrameSequence>&GetCharacterAnimation(const uint8_t animInd,const SkinTone tone); //Provide the EXACT index of the character you want from the character images in gfx. NOTE: They are 1-indexed! Use 1 for the first one etc.
|
||||
|
||||
const bool GetInput(const Action&actionName);
|
||||
const bool GetInputPressed(const Action&actionName);
|
||||
const bool GetInputReleased(const Action&actionName);
|
||||
private:
|
||||
|
||||
static ShepGame*game;
|
||||
|
@ -57,9 +57,47 @@ void Theme::Initialize(){
|
||||
std::cout<<"Theme sheet loaded"<<std::endl;
|
||||
}
|
||||
void Theme::DrawWindow(const geom2d::rect<int>window){
|
||||
static float t{};
|
||||
|
||||
auto&game{ShepGame::Game()};
|
||||
geom2d::rect<int>windowFrame{window.pos-vf2d{4,4},window.size+vf2d{8,8}};
|
||||
game.FillRectDecal(windowFrame.pos-vf2d{2,2},windowFrame.size+vf2d{4,4},BLACK);
|
||||
game.DrawPartialDecal(windowFrame.pos-vf2d{8,8},sheet.Decal(),{0.f,float(currentTheme*160)},{16.f,16.f},{2,2});
|
||||
game.DrawPartialDecal(windowFrame.pos+windowFrame.size-vf2d{24,24},sheet.Decal(),{0.f,float(currentTheme*160)},{16.f,16.f},{2,2});
|
||||
game.DrawPartialDecal(windowFrame.pos+vf2d{float(windowFrame.size.x),0.f}-vf2d{24,8},sheet.Decal(),{0.f,float(currentTheme*160)},{16.f,16.f},{2,2});
|
||||
game.DrawPartialDecal(windowFrame.pos+vf2d{0.f,float(windowFrame.size.y)}-vf2d{8,24},sheet.Decal(),{0.f,float(currentTheme*160)},{16.f,16.f},{2,2});
|
||||
Pixel transparentThemeColor{backCol.at(Color(currentTheme)).r,backCol.at(Color(currentTheme)).g,backCol.at(Color(currentTheme)).b,0};
|
||||
|
||||
t+=0.4f*game.GetElapsedTime();
|
||||
|
||||
const auto DrawRotatingGradientRectDecal=[&game](const geom2d::rect<float>&rect,const Pixel col,const float&t,const bool rotatesRight=true){
|
||||
float p{rect.perimeter()};
|
||||
|
||||
Pixel c1{col},c2{col},c3{col},c4{col};
|
||||
|
||||
float TL{0.f};
|
||||
float TR{rect.top().length()/p};
|
||||
float BR{0.5f};
|
||||
float BL{TR+BR};
|
||||
|
||||
c4.a=abs(0.5-(std::fmod(t,1.f)))*255*2;
|
||||
c3.a=abs(0.5-(std::fmod(t+0.25f,1.f)))*255*2;
|
||||
c2.a=abs(0.5-(std::fmod(t+0.5f,1.f)))*255*2;
|
||||
c1.a=abs(0.5-(std::fmod(t+0.75f,1.f)))*255*2;
|
||||
|
||||
if(rotatesRight){
|
||||
c1.a=255-c1.a;
|
||||
c2.a=255-c2.a;
|
||||
c3.a=255-c3.a;
|
||||
c4.a=255-c4.a;
|
||||
}
|
||||
|
||||
game.GradientFillRectDecal(rect.pos,rect.size,c1,c2,c3,c4);
|
||||
};
|
||||
|
||||
DrawRotatingGradientRectDecal(geom2d::rect<float>{windowFrame.pos,windowFrame.size},backCol.at(Color(currentTheme)),t);
|
||||
DrawRotatingGradientRectDecal(geom2d::rect<float>{windowFrame.pos+vf2d{2,2},windowFrame.size-vf2d{4,4}},BLACK,t,false);
|
||||
game.FillRectDecal(window.pos,window.size,backCol.at(Color(currentTheme)));
|
||||
game.DrawStringPropDecal(window.pos,"Hello World!!",WHITE,{4,4});
|
||||
}
|
||||
void Theme::ToggleNext(){
|
||||
currentTheme++;
|
||||
|
44
src/Trigger.cpp
Normal file
44
src/Trigger.cpp
Normal file
@ -0,0 +1,44 @@
|
||||
#pragma region License
|
||||
/*
|
||||
License (OLC-3)
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
Copyright 2024 Joshua Sigona <sigonasr2@gmail.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.
|
||||
|
||||
Portions of this software are copyright © 2024 The FreeType
|
||||
Project (www.freetype.org). Please see LICENSE_FT.txt for more information.
|
||||
All rights reserved.
|
||||
*/
|
||||
#pragma endregion
|
||||
|
||||
#include "Trigger.h"
|
||||
Trigger::Trigger(const std::function<void()>&trigger)
|
||||
:triggerFunc(trigger){}
|
||||
void Trigger::trigger(){
|
||||
triggerFunc();
|
||||
}
|
48
src/Trigger.h
Normal file
48
src/Trigger.h
Normal file
@ -0,0 +1,48 @@
|
||||
#pragma region License
|
||||
/*
|
||||
License (OLC-3)
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
Copyright 2024 Joshua Sigona <sigonasr2@gmail.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.
|
||||
|
||||
Portions of this software are copyright © 2024 The FreeType
|
||||
Project (www.freetype.org). Please see LICENSE_FT.txt for more information.
|
||||
All rights reserved.
|
||||
*/
|
||||
#pragma endregion
|
||||
#pragma once
|
||||
#include <functional>
|
||||
|
||||
//A class that you use to specify an action at the end of a trigger.
|
||||
class Trigger{
|
||||
public:
|
||||
Trigger(const std::function<void()>&trigger);
|
||||
void trigger();
|
||||
private:
|
||||
std::function<void()>triggerFunc;
|
||||
};
|
@ -4813,13 +4813,13 @@ namespace olc
|
||||
fontRenderable.Decal()->Update();
|
||||
|
||||
constexpr std::array<uint8_t, 96> vSpacing = { {
|
||||
0x03,0x02,0x04,0x03,0x06,0x0B,0x0A,0x03,0x04,0x04,0x04,0x06,0x03,0x03,0x03,0x05,
|
||||
0x06,0x05,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x02,0x03,0x05,0x06,0x05,0x05,
|
||||
0x05,0x07,0x06,0x06,0x06,0x05,0x05,0x06,0x06,0x02,0x05,0x06,0x05,0x08,0x06,0x06,
|
||||
0x06,0x06,0x06,0x06,0x06,0x06,0x07,0x08,0x06,0x06,0x05,0x06,0x05,0x07,0x05,0x06,
|
||||
0x03,0x06,0x05,0x05,0x05,0x05,0x04,0x05,0x05,0x02,0x03,0x05,0x02,0x08,0x05,0x05,
|
||||
0x05,0x05,0x04,0x05,0x04,0x05,0x06,0x08,0x05,0x05,0x05,0x03,0x06,0x03,0x07,0x08, } };
|
||||
for (auto c : vSpacing) vFontSpacing.push_back({ c >> 4, c & 15 });
|
||||
0x43,0x52,0x44,0x43,0x46,0x4B,0x4A,0x43,0x44,0x44,0x44,0x46,0x43,0x43,0x43,0x45,
|
||||
0x46,0x45,0x46,0x46,0x46,0x46,0x46,0x46,0x46,0x46,0x42,0x43,0x45,0x46,0x45,0x45,
|
||||
0x45,0x47,0x46,0x46,0x46,0x45,0x45,0x46,0x46,0x42,0x45,0x46,0x45,0x48,0x46,0x46,
|
||||
0x46,0x46,0x46,0x46,0x46,0x46,0x47,0x48,0x46,0x46,0x45,0x46,0x45,0x47,0x45,0x46,
|
||||
0x43,0x46,0x45,0x45,0x45,0x45,0x44,0x45,0x45,0x42,0x43,0x45,0x42,0x48,0x45,0x45,
|
||||
0x45,0x45,0x44,0x45,0x44,0x45,0x46,0x48,0x45,0x45,0x45,0x43,0x46,0x43,0x47,0x48, } };
|
||||
for (auto c : vSpacing) vFontSpacing.push_back({ c >> 4, (c & 15) + 1 });
|
||||
|
||||
// UK Standard Layout
|
||||
#ifdef OLC_KEYBOARD_UK
|
||||
|
Loading…
x
Reference in New Issue
Block a user