Initial Commit
This commit is contained in:
9
include/Editor.hpp
Normal file
9
include/Editor.hpp
Normal file
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
class Editor {
|
||||
public:
|
||||
protected:
|
||||
private:
|
||||
|
||||
|
||||
}
|
150
include/EditorApp.hpp
Normal file
150
include/EditorApp.hpp
Normal file
@@ -0,0 +1,150 @@
|
||||
#pragma once
|
||||
#include <ReWindow/types/Window.h>
|
||||
|
||||
#include "JGL/JGL.h"
|
||||
#include "JUI/Widgets/Scene.hpp"
|
||||
#include "JUI/Widgets/UtilityBar.hpp"
|
||||
|
||||
#define GL_VER_MAJOR 2
|
||||
#define GL_VER_MINOR 1
|
||||
|
||||
using namespace ReWindow;
|
||||
using namespace JUI::UDimLiterals;
|
||||
|
||||
class EditorApp : public OpenGLWindow {
|
||||
public:
|
||||
JUI::Scene* scene;
|
||||
|
||||
EditorApp() : OpenGLWindow("Editor App", 1080, 768, GL_VER_MAJOR, GL_VER_MINOR) {
|
||||
|
||||
}
|
||||
|
||||
void CreateWidgets() {
|
||||
scene = new JUI::Scene();
|
||||
|
||||
|
||||
auto* topbar = new JUI::UtilityBar(scene);
|
||||
|
||||
|
||||
auto* file = topbar->AddSubmenu("File");
|
||||
file->SetFont(JGL::Fonts::Jupiteroid);
|
||||
file->AddButton("New");
|
||||
file->AddButton("Open");
|
||||
file->AddButton("Save");
|
||||
file->AddButton("Save As");
|
||||
file->AddSeparator(2_px);
|
||||
file->AddButton("About");
|
||||
file->AddButton("Preferences");
|
||||
|
||||
auto* edit = topbar->AddSubmenu("Edit");
|
||||
edit->AddButton("Undo");
|
||||
edit->AddButton("Redo");
|
||||
edit->AddButton("Copy");
|
||||
edit->AddSeparator(2_px);
|
||||
edit->AddButton("Paste");
|
||||
edit->AddButton("Cut Selection");
|
||||
|
||||
auto* view = topbar->AddSubmenu("View");
|
||||
view->AddButton("Zoom In");
|
||||
view->AddButton("Zoom Out");
|
||||
view->AddSeparator(2_px);
|
||||
view->AddButton("Toggle Grid");
|
||||
|
||||
auto* level = topbar->AddSubmenu("Level");
|
||||
auto* layer = topbar->AddSubmenu("Layer");
|
||||
layer->AddButton("New");
|
||||
layer->AddButton("Open from File");
|
||||
layer->AddButton("Duplicate Selected");
|
||||
layer->AddButton("Delete Selected");
|
||||
layer->AddButton("Edit Selected");
|
||||
layer->AddButton("Export Layer");
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
bool Open() override {
|
||||
if (!OpenGLWindow::Open()) return false;
|
||||
|
||||
auto size = GetSize();
|
||||
auto vec_size = Vector2i(size.x, size.y);
|
||||
if (!JGL::Init(vec_size, 0.f, 1.f))
|
||||
return false;
|
||||
JGL::Update(vec_size);
|
||||
|
||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthFunc(GL_LESS);
|
||||
glDepthMask(GL_TRUE);
|
||||
// TODO: Delete when we update to the next release of JGL
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1); // NOTE: This MUST be called for text rendering to work properly!!!
|
||||
|
||||
CreateWidgets();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Update(float elapsed) {
|
||||
auto size = GetSize();
|
||||
Vector2i vSize = Vector2i(size.x, size.y);
|
||||
|
||||
|
||||
JGL::Update(vSize);
|
||||
scene->SetViewportSize(Vector2(vSize));
|
||||
scene->Update(elapsed);
|
||||
}
|
||||
|
||||
void Draw() {
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
//glMatrixMode(GL_MODELVIEW);
|
||||
//glLoadIdentity();
|
||||
|
||||
|
||||
J2D::Begin();
|
||||
|
||||
J2D::End();
|
||||
|
||||
scene->Draw();
|
||||
}
|
||||
|
||||
void OnRefresh(float elapsed) override {
|
||||
Update(elapsed);
|
||||
Draw();
|
||||
SwapBuffers();
|
||||
}
|
||||
|
||||
enum JUI::MouseButton ToJUIEnum(const MouseButton& btn) {
|
||||
if (btn == MouseButtons::Left) return JUI::MouseButton::Left;
|
||||
if (btn == MouseButtons::Middle) return JUI::MouseButton::Middle;
|
||||
if (btn == MouseButtons::Right) return JUI::MouseButton::Right;
|
||||
|
||||
// Default condition.
|
||||
return JUI::MouseButton::Left;
|
||||
}
|
||||
|
||||
void OnMouseButtonDown(const MouseButtonDownEvent &e) override {
|
||||
auto btn = ToJUIEnum(e.Button);
|
||||
|
||||
if (scene->ObserveMouseInput(btn, true)) return;
|
||||
}
|
||||
|
||||
void OnMouseButtonUp(const MouseButtonUpEvent &e) override {
|
||||
auto btn = ToJUIEnum(e.Button);
|
||||
if (scene->ObserveMouseInput(btn, false)) return;
|
||||
}
|
||||
|
||||
void OnMouseMove(const MouseMoveEvent &e) override {
|
||||
Vector2 mposv2(e.Position.x, e.Position.y);
|
||||
if (scene->ObserveMouseMovement(mposv2)) return;
|
||||
}
|
||||
|
||||
void OnKeyDown(const KeyDownEvent &e) override {
|
||||
if (scene->ObserveKeyInput(e.key, true)) return;
|
||||
}
|
||||
|
||||
void OnKeyUp(const KeyUpEvent &e) override {
|
||||
if (scene->ObserveKeyInput(e.key, false)) return;
|
||||
}
|
||||
};
|
8
include/Entity.hpp
Normal file
8
include/Entity.hpp
Normal file
@@ -0,0 +1,8 @@
|
||||
//
|
||||
// Created by dawsh on 5/12/25.
|
||||
//
|
||||
|
||||
#ifndef ENTITY_HPP
|
||||
#define ENTITY_HPP
|
||||
|
||||
#endif //ENTITY_HPP
|
8
include/Layer.hpp
Normal file
8
include/Layer.hpp
Normal file
@@ -0,0 +1,8 @@
|
||||
//
|
||||
// Created by dawsh on 5/12/25.
|
||||
//
|
||||
|
||||
#ifndef LAYER_HPP
|
||||
#define LAYER_HPP
|
||||
|
||||
#endif //LAYER_HPP
|
8
include/Level.hpp
Normal file
8
include/Level.hpp
Normal file
@@ -0,0 +1,8 @@
|
||||
//
|
||||
// Created by dawsh on 5/12/25.
|
||||
//
|
||||
|
||||
#ifndef LEVEL_HPP
|
||||
#define LEVEL_HPP
|
||||
|
||||
#endif //LEVEL_HPP
|
16
include/TileLayer.hpp
Normal file
16
include/TileLayer.hpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
struct TileCell {
|
||||
|
||||
};
|
||||
|
||||
class TileLayer {
|
||||
public:
|
||||
int rows;
|
||||
int cols;
|
||||
int cell_width;
|
||||
int cell_height;
|
||||
TileCell cells[][];
|
||||
protected:
|
||||
private:
|
||||
};
|
8
include/Tileset.hpp
Normal file
8
include/Tileset.hpp
Normal file
@@ -0,0 +1,8 @@
|
||||
//
|
||||
// Created by dawsh on 5/12/25.
|
||||
//
|
||||
|
||||
#ifndef TILESET_HPP
|
||||
#define TILESET_HPP
|
||||
|
||||
#endif //TILESET_HPP
|
Reference in New Issue
Block a user