Skip to content

Commit

Permalink
Add a new font editor
Browse files Browse the repository at this point in the history
  • Loading branch information
mniip committed Apr 29, 2018
1 parent 04c8751 commit c0c550e
Show file tree
Hide file tree
Showing 5 changed files with 637 additions and 4 deletions.
16 changes: 12 additions & 4 deletions SConscript
Expand Up @@ -67,6 +67,7 @@ AddSconsOption('static', False, False, "Compile statically.")
AddSconsOption('opengl', False, False, "Build with OpenGL interface support.")
AddSconsOption('opengl-renderer', False, False, "Build with OpenGL renderer support (turns on --opengl).") #Note: this has nothing to do with --renderer, only tells the game to render particles with opengl
AddSconsOption('renderer', False, False, "Build the save renderer.")
AddSconsOption('font', False, False, "Build the font editor.")

AddSconsOption('wall', False, False, "Error on all warnings.")
AddSconsOption('no-warnings', False, False, "Disable all compiler warnings.")
Expand Down Expand Up @@ -266,7 +267,7 @@ def findLibs(env, conf):
else:
FatalError("SDL.h not found")

if not GetOption('nolua') and not GetOption('renderer'):
if not GetOption('nolua') and not GetOption('renderer') and not GetOption('font'):
#Look for Lua
if platform == "FreeBSD":
luaver = "lua-5.1"
Expand Down Expand Up @@ -494,7 +495,7 @@ if GetOption('static'):
#Add other flags and defines
if not GetOption('nofft'):
env.Append(CPPDEFINES=['GRAVFFT'])
if not GetOption('nolua') and not GetOption('renderer'):
if not GetOption('nolua') and not GetOption('renderer') and not GetOption('font'):
env.Append(CPPDEFINES=['LUACONSOLE'])

if GetOption('opengl') or GetOption('opengl-renderer'):
Expand All @@ -507,6 +508,9 @@ if GetOption('renderer'):
else:
env.Append(CPPDEFINES=['USE_SDL'])

if GetOption('font'):
env.Append(CPPDEFINES=['FONTEDITOR'])

if GetOption("wall"):
if msvc:
env.Append(CCFLAGS=['/WX'])
Expand Down Expand Up @@ -540,7 +544,7 @@ if GetOption('beta'):

#Generate list of sources to compile
sources = Glob("src/*.cpp") + Glob("src/*/*.cpp") + Glob("src/*/*/*.cpp") + Glob("generated/*.cpp")
if not GetOption('nolua') and not GetOption('renderer'):
if not GetOption('nolua') and not GetOption('renderer') and not GetOption('font'):
sources += Glob("src/lua/socket/*.c") + Glob("src/lua/LuaCompat.c")

if platform == "Windows":
Expand All @@ -559,7 +563,11 @@ elif platform == "Darwin":
if GetOption('output'):
programName = GetOption('output')
else:
programName = GetOption('renderer') and "render" or "powder"
programName = "powder"
if GetOption('renderer'):
programName = "render"
if GetOption('font'):
programName = "font"
if "BIT" in env and env["BIT"] == 64:
programName += "64"
if isX86 and GetOption('no-sse'):
Expand Down
5 changes: 5 additions & 0 deletions data/font.h
@@ -1,6 +1,7 @@
#ifndef FONT_H_CHECK
#define FONT_H_CHECK
#define FONT_H 12
#ifndef FONTEDITOR
#ifdef INCLUDE_FONTDATA
unsigned char font_data[] = {
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Expand Down Expand Up @@ -299,5 +300,9 @@ short font_ptrs[] = {
extern unsigned char font_data[];
extern short font_ptrs[];
#endif
#else
extern unsigned char *font_data;
extern short *font_ptrs;
#endif
#endif

9 changes: 9 additions & 0 deletions src/PowderToySDL.cpp
Expand Up @@ -50,6 +50,8 @@ extern "C" {
#include "gui/game/GameController.h"
#include "gui/game/GameView.h"

#include "gui/font/FontEditor.h"

#include "gui/dialogues/ErrorMessage.h"
#include "gui/dialogues/ConfirmPrompt.h"
#include "gui/interface/Keys.h"
Expand Down Expand Up @@ -1108,6 +1110,7 @@ int main(int argc, char * argv[])
try {
#endif

#ifndef FONTEDITOR
gameController = new GameController();
engine->ShowWindow(gameController->GetView());

Expand Down Expand Up @@ -1204,6 +1207,12 @@ int main(int argc, char * argv[])
}
}

#else // FONTEDITOR
if(argc <= 1)
throw std::runtime_error("Not enough arguments");
engine->ShowWindow(new FontEditor(argv[1]));
#endif

//initial mouse coords
int sdl_x, sdl_y;
SDL_GetMouseState(&sdl_x, &sdl_y);
Expand Down

0 comments on commit c0c550e

Please sign in to comment.