Moved source file locations for easier compiling; cleaned up Makefile; cleaned up opengl code
This commit is contained in:
95
source/engine/editor/ed_project.c
Normal file
95
source/engine/editor/ed_project.c
Normal file
@@ -0,0 +1,95 @@
|
||||
#include "ed_project.h"
|
||||
|
||||
#include "editor.h"
|
||||
|
||||
void editor_init_project(struct gameproject *gp)
|
||||
{
|
||||
/*
|
||||
cur_project = gp;
|
||||
DATA_PATH = strdup(gp->path);
|
||||
stemlen = strlen(DATA_PATH);
|
||||
findPrefabs();
|
||||
get_levels();
|
||||
get_all_files();
|
||||
*/
|
||||
}
|
||||
|
||||
void editor_make_project(char *path)
|
||||
{
|
||||
FILE *f = path_open("w", "%s%s", path, "/project.yugh");
|
||||
cur_project =
|
||||
(struct gameproject *) malloc(sizeof(struct gameproject));
|
||||
strncpy(cur_project->name, "New Game", 127);
|
||||
strncpy(cur_project->path, path, 2048);
|
||||
vec_add(projects, cur_project);
|
||||
fwrite(cur_project, sizeof(*cur_project), 1, f);
|
||||
fclose(f);
|
||||
|
||||
editor_init_project(cur_project);
|
||||
|
||||
editor_save_projects();
|
||||
}
|
||||
|
||||
void editor_import_project(char *path)
|
||||
{
|
||||
FILE *f = path_open("r", "%s%s", path, "/project.yugh");
|
||||
if (!f)
|
||||
return;
|
||||
|
||||
struct gameproject *gp = (struct gameproject *) malloc(sizeof(*gp));
|
||||
fread(gp, sizeof(*gp), 1, f);
|
||||
fclose(f);
|
||||
|
||||
vec_add(projects, gp);
|
||||
}
|
||||
|
||||
void editor_project_btn_gui(struct gameproject *gp)
|
||||
{
|
||||
/*
|
||||
if (ImGui::Button(gp->name))
|
||||
editor_init_project(gp);
|
||||
|
||||
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("%s", gp->path);
|
||||
*/
|
||||
}
|
||||
|
||||
void editor_proj_select_gui()
|
||||
{
|
||||
/*
|
||||
ImGui::Begin("Project Select");
|
||||
|
||||
vec_walk(projects, (void (*)(void *)) &editor_project_btn_gui);
|
||||
|
||||
ImGui::InputText("Project import path", setpath, MAXPATH);
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Create")) {
|
||||
editor_make_project(setpath);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Import")) {
|
||||
editor_import_project(setpath);
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
void editor_load_projects()
|
||||
{
|
||||
FILE *f = fopen("projects.yugh", "r");
|
||||
if (!f)
|
||||
return;
|
||||
|
||||
vec_load(projects, f);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
void editor_save_projects()
|
||||
{
|
||||
FILE *f = fopen("projects.yugh", "w");
|
||||
vec_store(projects, f);
|
||||
fclose(f);
|
||||
}
|
||||
18
source/engine/editor/ed_project.h
Normal file
18
source/engine/editor/ed_project.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef ED_PROJECT_H
|
||||
#define ED_PROJECT_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
struct gameproject {
|
||||
char name[127];
|
||||
char path[MAXPATH];
|
||||
};
|
||||
|
||||
void editor_init_project(struct gameproject *gp);
|
||||
void editor_save_projects();
|
||||
void editor_load_projects();
|
||||
void editor_proj_select_gui();
|
||||
void editor_import_project(char *path);
|
||||
void editor_make_project(char *path);
|
||||
|
||||
#endif
|
||||
1019
source/engine/editor/editor.c
Normal file
1019
source/engine/editor/editor.c
Normal file
File diff suppressed because it is too large
Load Diff
108
source/engine/editor/editor.h
Normal file
108
source/engine/editor/editor.h
Normal file
@@ -0,0 +1,108 @@
|
||||
#ifndef EDITOR_H
|
||||
#define EDITOR_H
|
||||
|
||||
#include <config.h>
|
||||
#include <stdbool.h>
|
||||
#include "resources.h"
|
||||
|
||||
#include "nuke.h"
|
||||
|
||||
#define ASSET_TYPE_NULL 0
|
||||
#define ASSET_TYPE_IMAGE 1
|
||||
#define ASSET_TYPE_TEXT 2
|
||||
#define ASSET_TYPE_SOUND 3
|
||||
|
||||
struct fileasset {
|
||||
char *filename;
|
||||
bool searched;
|
||||
short type;
|
||||
void *data; // Struct of the underlying asset - Texture struct, etc
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
bool show;
|
||||
struct nk_rect rect;
|
||||
} editor_win;
|
||||
|
||||
struct editorVars {
|
||||
editor_win stats;
|
||||
editor_win hierarchy;
|
||||
editor_win gamesettings;
|
||||
editor_win viewmode;
|
||||
editor_win debug;
|
||||
editor_win assets;
|
||||
editor_win asset;
|
||||
editor_win repl;
|
||||
editor_win export;
|
||||
editor_win level;
|
||||
editor_win gameobject;
|
||||
editor_win components;
|
||||
editor_win simulate;
|
||||
editor_win prefab;
|
||||
nk_flags text_ed;
|
||||
nk_flags asset_srch;
|
||||
};
|
||||
|
||||
struct gameobject;
|
||||
|
||||
extern int show_desktop;
|
||||
|
||||
#define NK_MENU_START(VAR) if (editor.VAR.show && !show_desktop) { \
|
||||
if (editor.VAR.rect.w == 0) editor.VAR.rect = nk_rect_std; \
|
||||
if (nk_begin(ctx, #VAR, editor.VAR.rect, nuk_std)) { \
|
||||
editor.VAR.rect = nk_window_get_bounds(ctx);
|
||||
|
||||
#define NK_MENU_END() } nk_end(ctx); }
|
||||
|
||||
#define NK_FORCE(VAR) if (editor.VAR.rect.w == 0) editor.VAR.rect = nk_rect_std; \
|
||||
if (!show_desktop && nk_begin(ctx, #VAR, editor.VAR.rect, nuk_std)) { \
|
||||
editor.VAR.rect = nk_window_get_bounds(ctx);
|
||||
|
||||
#define NK_FORCE_END() nk_end(ctx); }
|
||||
|
||||
#define NEGATE(VAR) VAR = ! VAR
|
||||
|
||||
struct vec;
|
||||
struct gameproject;
|
||||
struct sprite;
|
||||
|
||||
extern struct gameproject *cur_project;
|
||||
extern struct vec *projects;
|
||||
|
||||
|
||||
struct Texture;
|
||||
struct window;
|
||||
|
||||
void pickGameObject(int pickID);
|
||||
int is_allowed_extension(const char *ext);
|
||||
|
||||
void editor_init(struct window *window);
|
||||
void editor_input();
|
||||
void editor_render();
|
||||
int editor_wantkeyboard();
|
||||
void editor_save();
|
||||
void editor_makenewobject();
|
||||
|
||||
void editor_project_gui();
|
||||
|
||||
void editor_selectasset(struct fileasset *asset);
|
||||
void editor_selectasset_str(const char *path);
|
||||
void editor_asset_gui(struct fileasset *asset);
|
||||
void editor_asset_tex_gui(struct Texture *tex);
|
||||
void editor_asset_text_gui(char *text);
|
||||
|
||||
void editor_level_btn(char *level);
|
||||
void editor_prefab_btn(char *prefab);
|
||||
|
||||
void game_start();
|
||||
void game_resume();
|
||||
void game_stop();
|
||||
void game_pause();
|
||||
|
||||
void get_levels();
|
||||
|
||||
int obj_gui_hierarchy(struct gameobject *selected);
|
||||
|
||||
void sprite_gui(struct sprite *sprite);
|
||||
|
||||
#endif
|
||||
19
source/engine/editor/editorstate.c
Normal file
19
source/engine/editor/editorstate.c
Normal file
@@ -0,0 +1,19 @@
|
||||
#include "editorstate.h"
|
||||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
void (*asset_command)(char *asset) = print_file;
|
||||
|
||||
void print_file(char *file)
|
||||
{
|
||||
YughInfo("File path: %s", file);
|
||||
}
|
||||
|
||||
void set_new_model(char *modelPath)
|
||||
{
|
||||
printf("Loading new model: %s\n", modelPath);
|
||||
curActor->model = GetExistingModel(modelPath);
|
||||
strcpy(curActor->currentModelPath, modelPath);
|
||||
}
|
||||
|
||||
*/
|
||||
10
source/engine/editor/editorstate.h
Normal file
10
source/engine/editor/editorstate.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef EDITORSTATE_H
|
||||
#define EDITORSTATE_H
|
||||
|
||||
void set_new_model(char *modelPath);
|
||||
|
||||
extern void (*asset_command)(char *asset);
|
||||
|
||||
void print_file(char *file);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user