Skip to content

Commit

Permalink
rep init
Browse files Browse the repository at this point in the history
  • Loading branch information
anomalou committed Jul 19, 2021
0 parents commit acb41ef
Show file tree
Hide file tree
Showing 116 changed files with 39,263 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.vscode
build
21 changes: 21 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
cmake_minimum_required(VERSION 3.0.0)
project(AbyssVision VERSION 0.1.0)

include(CTest)

set(PROJECT_DIR "C:/Projects/AbyssVision") #set full path here

file(GLOB_RECURSE SOURCES ${PROJECT_DIR}/include/*.h ${PROJECT_DIR}/src/*.cpp)

set(SDL2_INCLUDE_DIR ${PROJECT_DIR}/sdl/include/SDL2)
set(SDL2_LIBRARY_DIR ${PROJECT_DIR}/sdl/lib)

add_executable(AbyssVision ${SOURCES})

target_include_directories(AbyssVision PUBLIC ${SDL2_INCLUDE_DIR})
target_include_directories(AbyssVision PUBLIC ${PROJECT_DIR}/include)
target_link_libraries(AbyssVision -lmingw32 ${SDL2_LIBRARY_DIR}/libSDL2main.a ${SDL2_LIBRARY_DIR}/libSDL2.dll.a ${SDL2_LIBRARY_DIR}/libSDL2_ttf.dll.a -mwindows)

set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
Binary file added SDL2.dll
Binary file not shown.
Binary file added SDL2_ttf.dll
Binary file not shown.
Binary file added arial.ttf
Binary file not shown.
24 changes: 24 additions & 0 deletions include/astring.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#ifndef ASTRING_H
#define ASTRING_H

#include <malloc.h>

namespace AbyssCore{
class AString{
private:
char* _str;
int length;

public:
AString();
AString(const char* str);

char* ToChars();
int Length();

public:
AString& operator=(const char* astr);
};
}

#endif
9 changes: 9 additions & 0 deletions include/colors.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef COLORS_H
#define COLORS_H

#define BLACK 0, 0, 0, 255
#define WHITE 255, 255, 255, 255
#define GRAY 200, 200, 200, 255
#define RED 255, 100, 100, 255

#endif
91 changes: 91 additions & 0 deletions include/core.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#ifndef CORE_H
#define CORE_H

#include <iostream>
#include <SDL.h>
#include <SDL_ttf.h>
#include <windowsgroup.h>
#include <solidgroup.h>
#include <window.h>
#include <mainwindow.h>
#include <astring.h>
#include <colors.h>
#include <windowproperty.h>

#define RESOLUTION_X 1280
#define RESOLUTION_Y 640

#define RENDERER_FLAGS SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC

#define FPS10 10
#define FPS30 30
#define FPS60 60
#define FPS120 120
#define FPSINF 1000

#define FPS FPS60

namespace AbyssCore{
class Core{
private:
bool isRunning;

SDL_Window* window;
SDL_Renderer* renderer;

SDL_Thread* renderThread;

IWindowsGroup* group;

public:
Core();
~Core();

private:
bool CreateWindow();
bool CreateRenderer();
void DisposeWindow();
void DisposeRenderer();

void DrawWindow(SDL_Renderer* render, Window* w);

static void DrawWindowHead(SDL_Renderer *render, Window* w);
static void DrawWindowBody(SDL_Renderer* render, Window* w);
static void DrawWindowControl(SDL_Renderer* render, Window* w);

void ProcessMouse(SDL_Event event);
void MoveMouse(SDL_Event event);
void DragMouse(SDL_Event event);
void ClickMouse(SDL_Event event);

bool InWindow(Window* w, int x, int y);
bool InHeader(Window* w, int x, int y);
bool InBody(Window* w, int x, int y);

bool CloseHit(int x, int y);
bool MinimazeHit(int x, int y);
bool ResizeHit(int x, int y);

void Input();
static int Render(void *rendPtr);

public:
bool Init();
void Start();
void Dispose();
};

typedef struct{
Core* corePtr;
}RenderPtrs;

static Core* core = nullptr;
static TTF_Font* font = nullptr;

bool InitCore();
void StartCore();
void DisposeCore();
void OpenFont(const char* filePath);
}

#endif
13 changes: 13 additions & 0 deletions include/mainwindow.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <window.h>

namespace AbyssCore{
class MainWindow : public Window{
public:
MainWindow();
};
}

#endif
30 changes: 30 additions & 0 deletions include/solidgroup.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#ifndef SOLIDGROUP_H
#define SOLIDGROUP_H

#include <windowsgroup.h>
#include <vector>

using namespace std;

namespace AbyssCore{
class SolidGroup : public IWindowsGroup{
private:
vector<Window*> windowsPull;
Window* focus;

protected:
virtual int FreeID();

public:
SolidGroup();
virtual vector<Window*> GetPull();
virtual bool Create(Window* window, AString* byName);
virtual bool Destroy(Window* window);
virtual Window* Find(AString* byName);
virtual Window* Find(int byID);
virtual void FocusWindow(Window* window);
virtual Window* CurrentFocus();
};
}

#endif
61 changes: 61 additions & 0 deletions include/window.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#ifndef WINDOW_H
#define WINDOW_H

#include <SDL.h>
#include <windowproperty.h>
#include <astring.h>
#include <colors.h>

namespace AbyssCore{
class Window{
protected:
bool canMinimaze;
bool canClose;
bool canResize;

protected:
int id;
AString* name;
SDL_Rect rect;
SDL_Color color;
bool isVisible;
bool isMinimazied;

protected:
SDL_Rect closeHitBox;
SDL_Rect minimazeHitBox;
SDL_Rect resizeHitBox;

public:
Window();

virtual int GetID();
virtual AString* GetName();
virtual SDL_Rect GetRect();
virtual SDL_Color GetColor();
virtual bool IsVisible();
virtual bool IsMinimazed();
virtual bool CanMinimaze();
virtual bool CanClose();
virtual bool CanResize();
virtual SDL_Rect GetCloseHitBox();
virtual SDL_Rect GetMinimazeHitBox();
virtual SDL_Rect GetResizeHitBox();
virtual void SetID(int id);
virtual void SetName(AString* name);
virtual void SetPos(int x, int y);
virtual void SetSize(int w, int h);
virtual void SetRect(SDL_Rect rect);
virtual void SetColor(SDL_Color color);
virtual void SetVisible(bool v);
virtual void SetMinimaze(bool m);
virtual void AllowMinimaze(bool b);
virtual void AllowClose(bool b);
virtual void AllowResize(bool b);

protected:
virtual void CalculateControlHitBox();
};
}

#endif
16 changes: 16 additions & 0 deletions include/windowproperty.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef WINDOWPROPERTY_H
#define WINDOWPROPERTY_H

#define HEADER_HEIGHT 30
#define CBUTTON_WIDTH 30
#define CSIGN_SIZE 20

#define MIN_WIDTH CBUTTON_WIDTH
#define MIN_HEIGHT CBUTTON_WIDTH

#define FONT_FAMILY "Gravity.otf"
#define FSIGN_WIDTH 10
#define FSIGN_HEIGHT 18
#define FSIZE 25

#endif
28 changes: 28 additions & 0 deletions include/windowsgroup.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#ifndef WINDOWSGROUP_H
#define WINDOWSGROUP_H

#include <SDL.h>
#include <window.h>
#include <vector>

#define START_ID 0

using namespace std;

namespace AbyssCore{
class IWindowsGroup{
protected:
virtual int FreeID() = 0;

public:
virtual vector<Window*> GetPull() = 0;
virtual bool Create(Window* window, AString* byName) = 0;
virtual bool Destroy(Window* window) = 0;
virtual Window* Find(AString* byName) = 0;
virtual Window* Find(int byID) = 0;
virtual void FocusWindow(Window* window) = 0;
virtual Window* CurrentFocus() = 0;
};
}

#endif
Loading

0 comments on commit acb41ef

Please sign in to comment.