├── .gitattributes
├── .gitignore
├── .travis.yml
├── CMakeLists.txt
├── Irrlicht.ico
├── README.md
├── cmake
├── FindIrrlicht.cmake
└── FindOpenGLES2.cmake
├── docs
├── developers.md
├── fileformat.md
├── make_install.md
└── projectfileformat.txt
├── editor.conf.example
├── examples
├── default_dirt.png
├── default_stone.png
├── wool_blue.png
├── wool_green.png
└── wool_red.png
├── media
├── coordinates.png
├── flip_x.png
├── flip_y.png
├── flip_z.png
├── fontlucida.png
├── gui_scale.png
├── icon.png
├── icon_mode_node.png
├── icon_mode_nodebox.png
├── icon_mode_texture.png
├── rotate_x.png
├── rotate_y.png
├── rotate_z.png
├── sky.jpg
├── texture_box.png
└── texture_terrain.png
├── nodeboxeditor.desktop
├── src
├── Configuration.cpp
├── Configuration.hpp
├── Editor.cpp
├── Editor.hpp
├── EditorState.cpp
├── EditorState.hpp
├── FileFormat
│ ├── CPP.cpp
│ ├── CPP.hpp
│ ├── FileFormat.cpp
│ ├── FileFormat.hpp
│ ├── Lua.cpp
│ ├── Lua.hpp
│ ├── NBE.cpp
│ ├── NBE.hpp
│ ├── helpers.cpp
│ ├── helpers.hpp
│ ├── obj.cpp
│ └── obj.hpp
├── GUIHelpers.cpp
├── GUIHelpers.hpp
├── MenuState.cpp
├── MenuState.hpp
├── common.hpp
├── conf_cmake.hpp.in
├── dialogs
│ ├── Dialog.hpp
│ ├── FileDialog.cpp
│ ├── FileDialog.hpp
│ ├── ImageDialog.cpp
│ ├── ImageDialog.hpp
│ ├── TextureDialog.cpp
│ └── TextureDialog.hpp
├── main.cpp
├── minetest.cpp
├── minetest.hpp
├── modes
│ ├── NBEditor.cpp
│ ├── NBEditor.hpp
│ ├── NodeEditor.cpp
│ ├── NodeEditor.hpp
│ ├── TextureEditor.cpp
│ └── TextureEditor.hpp
├── project
│ ├── media.cpp
│ ├── media.hpp
│ ├── node.cpp
│ ├── node.hpp
│ ├── nodebox.cpp
│ ├── nodebox.hpp
│ ├── project.cpp
│ └── project.hpp
└── util
│ ├── SimpleFileCombiner.cpp
│ ├── SimpleFileCombiner.hpp
│ ├── filesys.cpp
│ ├── filesys.hpp
│ ├── string.cpp
│ ├── string.hpp
│ ├── tinyfiledialogs.c
│ └── tinyfiledialogs.h
└── util
├── buildbot
├── buildwin32.sh
├── buildwin64.sh
├── toolchain_mingw.cmake
└── toolchain_mingw64.cmake
├── install_nbe.sh
└── travis
├── before_install.sh
├── script.sh
└── toolchain_mingw.cmake.in
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 | *.sln merge=union
7 | *.csproj merge=union
8 | *.vbproj merge=union
9 | *.fsproj merge=union
10 | *.dbproj merge=union
11 |
12 | # Standard to msysgit
13 | *.doc diff=astextplain
14 | *.DOC diff=astextplain
15 | *.docx diff=astextplain
16 | *.DOCX diff=astextplain
17 | *.dot diff=astextplain
18 | *.DOT diff=astextplain
19 | *.pdf diff=astextplain
20 | *.PDF diff=astextplain
21 | *.rtf diff=astextplain
22 | *.RTF diff=astextplain
23 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Build
2 | bin
3 |
4 | # Build system
5 | CMakeCache.txt
6 | CMakeFiles
7 | cmake*
8 | Makefile
9 |
10 | # Configuration/generated
11 | editor.conf
12 | debug.txt
13 | conf_cmake.hpp
14 | install_manifest.txt
15 | *.nbe
16 | *.lua
17 | *.obj
18 |
19 | #################
20 | ## Eclipse
21 | #################
22 |
23 | # Build directories
24 | build
25 | Build
26 |
27 | # Locally stored "Eclipse launch configurations"
28 | *.launch
29 |
30 | # CDT-specific
31 | .cproject
32 |
33 | # PDT-specific
34 | .buildpath
35 |
36 |
37 | #################
38 | ## Visual Studio
39 | #################
40 |
41 | ## Ignore Visual Studio temporary files, build results, and
42 | ## files generated by popular Visual Studio add-ons.
43 |
44 | # User-specific files
45 | *.suo
46 | *.user
47 | *.sln.docstates
48 |
49 | # Build results
50 | [Dd]ebug/
51 | [Rr]elease/
52 | *_i.c
53 | *_p.c
54 | *.ilk
55 | *.meta
56 | *.obj
57 | *.pch
58 | *.pdb
59 | *.pgc
60 | *.pgd
61 | *.rsp
62 | *.sbr
63 | *.tlb
64 | *.tli
65 | *.tlh
66 | *.tmp
67 | *.vspscc
68 | .builds
69 | *.dotCover
70 |
71 | ## TODO: If you have NuGet Package Restore enabled, uncomment this
72 | #packages/
73 |
74 | # Visual C++ cache files
75 | ipch/
76 | *.aps
77 | *.ncb
78 | *.opensdf
79 | *.sdf
80 |
81 | # Visual Studio profiler
82 | *.psess
83 | *.vsp
84 |
85 | # ReSharper is a .NET coding add-in
86 | _ReSharper*
87 |
88 | # Installshield output folder
89 | [Ee]xpress
90 |
91 | # DocProject is a documentation generator add-in
92 | DocProject/buildhelp/
93 | DocProject/Help/*.HxT
94 | DocProject/Help/*.HxC
95 | DocProject/Help/*.hhc
96 | DocProject/Help/*.hhk
97 | DocProject/Help/*.hhp
98 | DocProject/Help/Html2
99 | DocProject/Help/html
100 |
101 | # Click-Once directory
102 | publish
103 |
104 | # Others
105 | [Bb]in
106 | [Oo]bj
107 | sql
108 | TestResults
109 | *.Cache
110 | ClientBin
111 | stylecop.*
112 | ~$*
113 | *.dbmdl
114 | Generated_Code #added for RIA/Silverlight projects
115 |
116 | # Backup & report files from converting an old project file to a newer
117 | # Visual Studio version. Backup files are not needed, because we have git ;-)
118 | _UpgradeReport_Files/
119 | Backup*/
120 | UpgradeLog*.XML
121 |
122 |
123 |
124 | ############
125 | ## Windows
126 | ############
127 |
128 | # Windows image file caches
129 | Thumbs.db
130 |
131 | # Folder config file
132 | Desktop.ini
133 |
134 | # Installer logs
135 | pip-log.txt
136 |
137 | # Unit test / coverage reports
138 | .coverage
139 | .tox
140 |
141 | #Translations
142 | *.mo
143 |
144 | #Mr Developer
145 | .mr.developer.cfg
146 |
147 | # Mac crap
148 | .DS_Store
149 |
150 | # Linux
151 | *~*
152 | .directory
153 | *kate-swp*
154 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: cpp
2 | compiler:
3 | - gcc
4 | - clang
5 | env:
6 | # - PLATFORM=Win32
7 | # - PLATFORM=Win64
8 | - PLATFORM=Linux
9 | before_install: ./util/travis/before_install.sh
10 | script: ./util/travis/script.sh
11 | matrix:
12 | fast_finish: true
13 | exclude:
14 | - env: PLATFORM=Win32
15 | compiler: clang
16 | - env: PLATFORM=Win64
17 | compiler: clang
18 |
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | #
2 | # Set up project
3 | #
4 | cmake_minimum_required(VERSION 2.6)
5 | project(nodeboxeditor)
6 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
7 |
8 | #
9 | # Configuration
10 | #
11 | set(NBE_MAJOR_VERSION 0)
12 | set(NBE_MINOR_VERSION 9)
13 | set(NBE_PATCH_VERSION 0)
14 | set(NBE_LABEL_VERSION "Obsidian Glass")
15 | option(DEBUG "Debug mode" 0)
16 | if(DEBUG)
17 | message("-- Is debug")
18 | set(IS_DEBUG true)
19 | endif(DEBUG)
20 | configure_file(
21 | "${PROJECT_SOURCE_DIR}/src/conf_cmake.hpp.in"
22 | "${PROJECT_BINARY_DIR}/conf_cmake.hpp"
23 | )
24 |
25 |
26 | #
27 | # Source files
28 | #
29 | set(NBE_SRC
30 | src/main.cpp
31 | src/Configuration.cpp
32 | src/GUIHelpers.cpp
33 | src/EditorState.cpp
34 | src/MenuState.cpp
35 | src/Editor.cpp
36 | src/minetest.cpp
37 |
38 | src/project/project.cpp
39 | src/project/media.cpp
40 | src/project/node.cpp
41 | src/project/nodebox.cpp
42 |
43 | src/modes/NBEditor.cpp
44 | src/modes/NodeEditor.cpp
45 | src/modes/TextureEditor.cpp
46 |
47 | src/dialogs/FileDialog.cpp
48 | src/dialogs/TextureDialog.cpp
49 | src/dialogs/ImageDialog.cpp
50 |
51 | src/FileFormat/FileFormat.cpp
52 | src/FileFormat/helpers.cpp
53 | src/FileFormat/NBE.cpp
54 | src/FileFormat/Lua.cpp
55 | src/FileFormat/CPP.cpp
56 | src/FileFormat/obj.cpp
57 |
58 | src/util/string.cpp
59 | src/util/filesys.cpp
60 | src/util/SimpleFileCombiner.cpp
61 | src/util/tinyfiledialogs.c
62 | )
63 | add_executable(${PROJECT_NAME} ${NBE_SRC})
64 |
65 | #
66 | # Dependencies
67 | #
68 | find_package(Irrlicht REQUIRED)
69 |
70 | if(WIN32)
71 | # Windows
72 | if(MSVC) # MSVC Specifics
73 | set(PLATFORM_LIBS dbghelp.lib ${PLATFORM_LIBS})
74 | # Surpress some useless warnings
75 | add_definitions ( /D "_CRT_SECURE_NO_DEPRECATE" /W1 )
76 | else() # Probably MinGW = GCC
77 | set(PLATFORM_LIBS "")
78 | endif()
79 | set(PLATFORM_LIBS ws2_32.lib shlwapi.lib ${PLATFORM_LIBS})
80 |
81 | # Zlib stuff
82 | set(ZLIB_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/../../zlib/zlib-1.2.5"
83 | CACHE PATH "Zlib include directory")
84 | set(ZLIB_LIBRARIES "${PROJECT_SOURCE_DIR}/../../zlib125dll/dll32/zlibwapi.lib"
85 | CACHE FILEPATH "Path to zlibwapi.lib")
86 | set(ZLIB_DLL "${PROJECT_SOURCE_DIR}/../../zlib125dll/dll32/zlibwapi.dll"
87 | CACHE FILEPATH "Path to zlibwapi.dll (for installation)")
88 | else(WIN32)
89 | find_package(ZLIB REQUIRED)
90 | endif(WIN32)
91 |
92 |
93 | find_package(X11 REQUIRED)
94 | find_package(OpenGL REQUIRED)
95 | find_package(JPEG REQUIRED)
96 | find_package(BZip2 REQUIRED)
97 | find_package(PNG REQUIRED)
98 | include_directories(
99 | ${PROJECT_BINARY_DIR}
100 | ${IRRLICHT_INCLUDE_DIR}
101 | ${ZLIB_INCLUDE_DIR}
102 | ${CMAKE_BUILD_TYPE}
103 | ${X11_INCLUDE_DIR}
104 | ${OPENGL_INCLUDE_DIR}
105 | ${PNG_INCLUDE_DIR}
106 | )
107 | set(TLL
108 | ${IRRLICHT_LIBRARY}
109 | ${ZLIB_LIBRARIES}
110 | ${X11_LIBRARIES}
111 | ${OPENGL_LIBRARIES}
112 | ${JPEG_LIBRARIES}
113 | ${BZIP2_LIBRARIES}
114 | ${PNG_LIBRARIES}
115 | )
116 | if(UNIX)
117 | find_library(XXF86VM_LIBRARY Xxf86vm)
118 | target_link_libraries(
119 | ${PROJECT_NAME}
120 | ${TLL}
121 | ${XXF86VM_LIBRARY}
122 | )
123 | else()
124 | target_link_libraries(
125 | ${PROJECT_NAME}
126 | ${TLL}
127 | )
128 | endif(UNIX)
129 |
130 | #
131 | # Executable
132 | #
133 | file(MAKE_DIRECTORY "bin")
134 | set(EXECUTABLE_OUTPUT_PATH "${CMAKE_SOURCE_DIR}/bin")
135 | set(CMAKE_CXX_FLAGS
136 | "${CMAKE_CXX_FLAGS} -pthread")
137 |
138 | #
139 | # Installation
140 | #
141 | install(FILES media/fontlucida.png DESTINATION share/nodeboxeditor/media)
142 | install(FILES media/gui_scale.png DESTINATION share/nodeboxeditor/media)
143 | install(FILES media/coordinates.png DESTINATION share/nodeboxeditor/media)
144 | install(FILES media/icon_mode_node.png DESTINATION share/nodeboxeditor/media)
145 | install(FILES media/icon_mode_nodebox.png DESTINATION share/nodeboxeditor/media)
146 | install(FILES media/icon_mode_texture.png DESTINATION share/nodeboxeditor/media)
147 | install(FILES media/sky.jpg DESTINATION share/nodeboxeditor/media)
148 | install(FILES media/texture_box.png DESTINATION share/nodeboxeditor/media)
149 | install(FILES media/texture_terrain.png DESTINATION share/nodeboxeditor/media)
150 | install(FILES media/icon.png DESTINATION share/nodeboxeditor/media)
151 | install(FILES media/rotate_x.png DESTINATION share/nodeboxeditor/media)
152 | install(FILES media/rotate_y.png DESTINATION share/nodeboxeditor/media)
153 | install(FILES media/rotate_z.png DESTINATION share/nodeboxeditor/media)
154 | install(FILES media/flip_x.png DESTINATION share/nodeboxeditor/media)
155 | install(FILES media/flip_y.png DESTINATION share/nodeboxeditor/media)
156 | install(FILES media/flip_z.png DESTINATION share/nodeboxeditor/media)
157 | install(FILES editor.conf.example DESTINATION share/nodeboxeditor)
158 | if(UNIX)
159 | install (FILES nodeboxeditor.desktop DESTINATION share/applications)
160 | endif()
161 | install(FILES README.md DESTINATION share/nodeboxeditor)
162 | install(TARGETS ${PROJECT_NAME} DESTINATION bin)
163 | if(WIN32)
164 | if(DEFINED IRRLICHT_DLL)
165 | install(FILES ${IRRLICHT_DLL} DESTINATION bin)
166 | endif()
167 | endif()
168 |
--------------------------------------------------------------------------------
/Irrlicht.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rubenwardy/NodeBoxEditor/a5ef5e4c0d07e44f32f088d9a10907fe8b008c73/Irrlicht.ico
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Node Box Editor
2 | ===============
3 |
4 | [](https://travis-ci.org/rubenwardy/NodeBoxEditor)
5 |
6 | Use this editor to make nodeboxes for nodes in Minetest.
7 |
8 | Version: 0.9.0
9 |
10 | To do list and bug tracker is here: https://github.com/rubenwardy/NodeBoxEditor/issues?state=open
11 |
12 | License
13 | -------
14 |
15 | Created by rubenwardy.
16 |
17 | GPL 3.0 or later.
18 |
19 | https://www.gnu.org/licenses/gpl-3.0.txt
20 |
21 | Contributors:
22 |
23 | * Kaeza: small Linux based fixes, and the start of the CMakeLists.txt (now modified)
24 | * Traxie21: small changed textures for node.
25 | * jmf: Fixed small compile bug fixes.
26 | * ShadowNinja: Unlimited node boxes, code style, refactoring and small fixes.
27 | * Krock/SmallJoker: Fixed warnings, fixed conf_cmake.hpp and Windows builds.
28 | * asl97: Fixed a memory leak.
29 |
30 | If I forgot anyone, please let me know.
31 |
32 | Building
33 | --------
34 |
35 | For notes on compiling the editor, see docs/developers.md
36 |
37 | Using the editor
38 | ================
39 |
40 | What actions you can take are limited by which mode / tool you are in.
41 |
42 | Editor
43 | ------
44 |
45 | * Use WASD to move the perspective view.
46 | * Use the options under view to pick which viewport to show.
47 | * Use the mode icon on the top left of the screen to change modes / tools.
48 | * Click the icon to pop out a list of modes / tools.
49 | * Click an icon to select the corresponding mode.
50 | * Press N to enter the node tool.
51 | * Press B to enter the node box tool.
52 | * Press T to enter the texture tool.
53 |
54 | Menu
55 | ----
56 |
57 | * File
58 | * Open Project - discard the current project and open a new one.
59 | * Save Project - save the current project.
60 | * Export - export the project to Lua, or other formats supported.
61 | * Exit - exit the editor.
62 | * Editor
63 | * Limiting - toggle whether node boxes can go outside of node boundaries.
64 | * Snapping - toggle whether node boxes will snap to a 16 pixel grid.
65 | * View - use these options to change the viewport (tiled, or make a viewport fullscreen).
66 | * Project - options unique to an tool.
67 | * Help
68 | * About - see program's version, and credits.
69 |
70 | Node Box Tool
71 | -------------
72 |
73 | In this mode / tool, you can edit the contents of a node.
74 | Icon: A blue cube with a chunk taken out of it.
75 |
76 | * Click + on the sidebar to add a node box. (or press insert)
77 | * Click an item in the listbox to select a node box. (or press up/down)
78 | * Click - on the sidebar to remove the selected node box. (or press delete)
79 | * Size the node box using the handles in the orthographic viewports.
80 | * Scale the node box by pressing control, and using the handles in the orthographic viewports.
81 | * Position the node box by pressing shift, and using the handles in the orthographic viewports.
82 | * Enter properties for a node box in the text boxes on the side bar.
83 | * Click update to apply your changes.
84 | * Click revert to discard your changes, and get the current properties.
85 |
86 | Node Tool
87 | ---------
88 |
89 | In this mode / tool, you can create multiple nodes and manage them.
90 | Icon: A yellow cube.
91 |
92 | * Click + on the sidebar to add a node. (or press insert)
93 | * Click an item in the listbox to select a node. (or press up/down)
94 | * Click - on the sidebar to remove the selected node. (or press delete)
95 |
96 | Texture Tool
97 | ------------
98 |
99 | In this mode / tool, you can edit the textures of a node.
100 | Icon: Red, green and blue cube.
101 |
102 | * Click a face in the side bar to open up the texture dialog.
103 | * Click import to import an texture.
104 | * Type the location relative to the NBE root if a portable build, or relative to the home directory if installed.
105 | * Click export to export the currently selected texture to the nbe root folder if portable, or the home directory if installed.
106 | * Click an texture in the list box to select it.
107 | * Click apply to apply the selected texture to the side of the node.
108 |
109 | Saving and Exporting
110 | --------------------
111 |
112 | The editor can currently save and export to several formats.
113 |
114 | * Node Box Editor file (nbe) - The file unique to this editor. General save / open format.
115 | * Lua file (lua) - Exports code which could be installed as a mod. Use when you want to run in Minetest.
116 | * Minetest Classic (cpp) - Exports code to be used in Minetest Classic. Use when you want to run in Minetest Classic.
117 |
--------------------------------------------------------------------------------
/cmake/FindIrrlicht.cmake:
--------------------------------------------------------------------------------
1 | #FindIrrlicht.cmake
2 |
3 | set(IRRLICHT_SOURCE_DIR "" CACHE PATH "Path to irrlicht source directory (optional)")
4 |
5 | if( UNIX )
6 | # Unix
7 | else( UNIX )
8 | # Windows
9 | endif( UNIX )
10 |
11 | # Find include directory
12 |
13 | if(NOT IRRLICHT_SOURCE_DIR STREQUAL "")
14 | set(IRRLICHT_SOURCE_DIR_INCLUDE
15 | "${IRRLICHT_SOURCE_DIR}/include"
16 | )
17 |
18 | set(IRRLICHT_LIBRARY_NAMES libIrrlicht.a Irrlicht Irrlicht.lib)
19 |
20 | if(WIN32)
21 | if(MSVC)
22 | set(IRRLICHT_SOURCE_DIR_LIBS "${IRRLICHT_SOURCE_DIR}/lib/Win32-visualstudio")
23 | set(IRRLICHT_LIBRARY_NAMES Irrlicht.lib)
24 | else()
25 | set(IRRLICHT_SOURCE_DIR_LIBS "${IRRLICHT_SOURCE_DIR}/lib/Win32-gcc")
26 | set(IRRLICHT_LIBRARY_NAMES libIrrlicht.a libIrrlicht.dll.a)
27 | endif()
28 | else()
29 | set(IRRLICHT_SOURCE_DIR_LIBS "${IRRLICHT_SOURCE_DIR}/lib/Linux")
30 | set(IRRLICHT_LIBRARY_NAMES libIrrlicht.a)
31 | endif()
32 |
33 | FIND_PATH(IRRLICHT_INCLUDE_DIR NAMES irrlicht.h
34 | PATHS
35 | ${IRRLICHT_SOURCE_DIR_INCLUDE}
36 | NO_DEFAULT_PATH
37 | )
38 |
39 | FIND_LIBRARY(IRRLICHT_LIBRARY NAMES ${IRRLICHT_LIBRARY_NAMES}
40 | PATHS
41 | ${IRRLICHT_SOURCE_DIR_LIBS}
42 | NO_DEFAULT_PATH
43 | )
44 |
45 | else()
46 |
47 | FIND_PATH(IRRLICHT_INCLUDE_DIR NAMES irrlicht.h
48 | PATHS
49 | /usr/local/include/irrlicht
50 | /usr/include/irrlicht
51 | )
52 |
53 | FIND_LIBRARY(IRRLICHT_LIBRARY NAMES libIrrlicht.a Irrlicht
54 | PATHS
55 | /usr/local/lib
56 | /usr/lib
57 | )
58 | endif()
59 |
60 | MESSAGE(STATUS "IRRLICHT_SOURCE_DIR = ${IRRLICHT_SOURCE_DIR}")
61 | MESSAGE(STATUS "IRRLICHT_INCLUDE_DIR = ${IRRLICHT_INCLUDE_DIR}")
62 | MESSAGE(STATUS "IRRLICHT_LIBRARY = ${IRRLICHT_LIBRARY}")
63 |
64 | # On windows, find the dll for installation
65 | if(WIN32)
66 | if(MSVC)
67 | FIND_FILE(IRRLICHT_DLL NAMES Irrlicht.dll
68 | PATHS
69 | "${IRRLICHT_SOURCE_DIR}/bin/Win32-VisualStudio"
70 | DOC "Path of the Irrlicht dll (for installation)"
71 | )
72 | else()
73 | FIND_FILE(IRRLICHT_DLL NAMES Irrlicht.dll
74 | PATHS
75 | "${IRRLICHT_SOURCE_DIR}/bin/Win32-gcc"
76 | DOC "Path of the Irrlicht dll (for installation)"
77 | )
78 | endif()
79 | MESSAGE(STATUS "IRRLICHT_DLL = ${IRRLICHT_DLL}")
80 | endif(WIN32)
81 |
82 | # handle the QUIETLY and REQUIRED arguments and set IRRLICHT_FOUND to TRUE if
83 | # all listed variables are TRUE
84 | INCLUDE(FindPackageHandleStandardArgs)
85 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(IRRLICHT DEFAULT_MSG IRRLICHT_LIBRARY IRRLICHT_INCLUDE_DIR)
86 |
87 | IF(IRRLICHT_FOUND)
88 | SET(IRRLICHT_LIBRARIES ${IRRLICHT_LIBRARY})
89 | ELSE(IRRLICHT_FOUND)
90 | SET(IRRLICHT_LIBRARIES)
91 | ENDIF(IRRLICHT_FOUND)
92 |
93 | MARK_AS_ADVANCED(IRRLICHT_LIBRARY IRRLICHT_INCLUDE_DIR IRRLICHT_DLL)
94 |
95 |
--------------------------------------------------------------------------------
/cmake/FindOpenGLES2.cmake:
--------------------------------------------------------------------------------
1 | #-------------------------------------------------------------------
2 | # This file is stolen from part of the CMake build system for OGRE (Object-oriented Graphics Rendering Engine) http://www.ogre3d.org/
3 | #
4 | # The contents of this file are placed in the public domain. Feel
5 | # free to make use of it in any way you like.
6 | #-------------------------------------------------------------------
7 |
8 | # - Try to find OpenGLES and EGL
9 | # Once done this will define
10 | #
11 | # OPENGLES2_FOUND - system has OpenGLES
12 | # OPENGLES2_INCLUDE_DIR - the GL include directory
13 | # OPENGLES2_LIBRARIES - Link these to use OpenGLES
14 | #
15 | # EGL_FOUND - system has EGL
16 | # EGL_INCLUDE_DIR - the EGL include directory
17 | # EGL_LIBRARIES - Link these to use EGL
18 |
19 | # win32, apple, android NOT TESED
20 | # linux tested and works
21 |
22 | IF (WIN32)
23 | IF (CYGWIN)
24 |
25 | FIND_PATH(OPENGLES2_INCLUDE_DIR GLES2/gl2.h )
26 |
27 | FIND_LIBRARY(OPENGLES2_gl_LIBRARY libGLESv2 )
28 |
29 | ELSE (CYGWIN)
30 |
31 | IF(BORLAND)
32 | SET (OPENGLES2_gl_LIBRARY import32 CACHE STRING "OpenGL ES 2.x library for win32")
33 | ELSE(BORLAND)
34 | # todo
35 | # SET (OPENGLES_gl_LIBRARY ${SOURCE_DIR}/Dependencies/lib/release/libGLESv2.lib CACHE STRING "OpenGL ES 2.x library for win32"
36 | ENDIF(BORLAND)
37 |
38 | ENDIF (CYGWIN)
39 |
40 | ELSE (WIN32)
41 |
42 | IF (APPLE)
43 |
44 | create_search_paths(/Developer/Platforms)
45 | findpkg_framework(OpenGLES2)
46 | set(OPENGLES2_gl_LIBRARY "-framework OpenGLES")
47 |
48 | ELSE(APPLE)
49 |
50 | FIND_PATH(OPENGLES2_INCLUDE_DIR GLES2/gl2.h
51 | /usr/openwin/share/include
52 | /opt/graphics/OpenGL/include /usr/X11R6/include
53 | /usr/include
54 | )
55 |
56 | FIND_LIBRARY(OPENGLES2_gl_LIBRARY
57 | NAMES GLESv2
58 | PATHS /opt/graphics/OpenGL/lib
59 | /usr/openwin/lib
60 | /usr/shlib /usr/X11R6/lib
61 | /usr/lib
62 | )
63 |
64 | IF (NOT BUILD_ANDROID)
65 | FIND_PATH(EGL_INCLUDE_DIR EGL/egl.h
66 | /usr/openwin/share/include
67 | /opt/graphics/OpenGL/include /usr/X11R6/include
68 | /usr/include
69 | )
70 |
71 | FIND_LIBRARY(EGL_egl_LIBRARY
72 | NAMES EGL
73 | PATHS /opt/graphics/OpenGL/lib
74 | /usr/openwin/lib
75 | /usr/shlib /usr/X11R6/lib
76 | /usr/lib
77 | )
78 |
79 | # On Unix OpenGL most certainly always requires X11.
80 | # Feel free to tighten up these conditions if you don't
81 | # think this is always true.
82 | # It's not true on OSX.
83 |
84 | IF (OPENGLES2_gl_LIBRARY)
85 | IF(NOT X11_FOUND)
86 | INCLUDE(FindX11)
87 | ENDIF(NOT X11_FOUND)
88 | IF (X11_FOUND)
89 | IF (NOT APPLE)
90 | SET (OPENGLES2_LIBRARIES ${X11_LIBRARIES})
91 | ENDIF (NOT APPLE)
92 | ENDIF (X11_FOUND)
93 | ENDIF (OPENGLES2_gl_LIBRARY)
94 | ENDIF ()
95 |
96 | ENDIF(APPLE)
97 | ENDIF (WIN32)
98 |
99 | #SET( OPENGLES2_LIBRARIES ${OPENGLES2_gl_LIBRARY} ${OPENGLES2_LIBRARIES})
100 |
101 | IF (BUILD_ANDROID)
102 | IF(OPENGLES2_gl_LIBRARY)
103 | SET( OPENGLES2_LIBRARIES ${OPENGLES2_gl_LIBRARY} ${OPENGLES2_LIBRARIES})
104 | SET( EGL_LIBRARIES)
105 | SET( OPENGLES2_FOUND "YES" )
106 | ENDIF(OPENGLES2_gl_LIBRARY)
107 | ELSE ()
108 |
109 | SET( OPENGLES2_LIBRARIES ${OPENGLES2_gl_LIBRARY} ${OPENGLES2_LIBRARIES})
110 |
111 | IF(OPENGLES2_gl_LIBRARY AND EGL_egl_LIBRARY)
112 | SET( OPENGLES2_LIBRARIES ${OPENGLES2_gl_LIBRARY} ${OPENGLES2_LIBRARIES})
113 | SET( EGL_LIBRARIES ${EGL_egl_LIBRARY} ${EGL_LIBRARIES})
114 | SET( OPENGLES2_FOUND "YES" )
115 | ENDIF(OPENGLES2_gl_LIBRARY AND EGL_egl_LIBRARY)
116 |
117 | ENDIF ()
118 |
119 | MARK_AS_ADVANCED(
120 | OPENGLES2_INCLUDE_DIR
121 | OPENGLES2_gl_LIBRARY
122 | EGL_INCLUDE_DIR
123 | EGL_egl_LIBRARY
124 | )
125 |
126 | IF(OPENGLES2_FOUND)
127 | MESSAGE(STATUS "Found system opengles2 library ${OPENGLES2_LIBRARIES}")
128 | ELSE ()
129 | SET(OPENGLES2_LIBRARIES "")
130 | ENDIF ()
131 |
--------------------------------------------------------------------------------
/docs/developers.md:
--------------------------------------------------------------------------------
1 | Introduction
2 | ============
3 |
4 | This guide contains technical information on installing, building, and maintaining the Node Box Editor
5 |
6 | Code Style
7 | ----------
8 |
9 | The project tries to follow [Minetest's code style](http://dev.minetest.net/Code_style_guidelines)
10 |
11 | GitHub things
12 | -------------
13 |
14 | Patches should be in their own branch when making a pull request.
15 |
16 | Do not pull request from upstream to your repo using GitHub's pull request and merge feature.
17 |
18 | Releasing a new version
19 | -----------------------
20 |
21 | * Bump settings in CMAKE.
22 | * Update README.md
23 | * Create windows build.
24 | * Write changelog.
25 | * Commit and push code to upstream.
26 | * Post message on Minetest forums.
27 | * Tag and release version on GitHub.
28 |
29 |
30 | Building and Installation
31 | =========================
32 |
33 | Linux
34 | -----
35 |
36 | **Install Dependencies**
37 |
38 | # download source and go to the root folder
39 | $ sudo apt-get install build-essential libirrlicht-dev cmake libpng-dev libbz2-dev libjpeg8-dev libgl1-mesa-dev libxxf86vm-dev
40 |
41 | **Compiling**
42 |
43 | # Compile the editor
44 | $ cmake .
45 | $ make -j2
46 |
47 | **Running**
48 |
49 | $ ./bin/nodeboxeditor
50 | # You could also double click the executable file in bin
51 |
52 | **Installing**
53 |
54 | $ sudo make install
55 | $ nodeboxeditor
56 | # See make_install.md
57 |
58 | Microsoft Visual Studio
59 | -----------------------
60 |
61 | Express edition makes no difference to the process.
62 |
63 | **Prerequisites**
64 |
65 | * Download Irrlicht. Some features in NBE require Irrlicht 1.8 or later in order to be enabled.
66 | * Download the source code for NBE
67 | * You will need to download Visual Studio, of course.
68 |
69 | **Step One: Set up a project**
70 |
71 | * Copy the conf_cmake.hpp.in to conf_cmake.hpp where you downloaded the source
72 | * Open up conf_cmake.hpp, and edit the defines where there is @NBE_A_SETTING@
73 | * @NBE_DESCR_VERSION@: "0.7 - Iron" for example
74 | * Create a C++ project in Visual Studio
75 | * Add the source code using right click > Add > Existing file. Make sure to include src/FileFormat and src/util as well.
76 |
77 | **Step Two: Adding Irrlicht**
78 |
79 | See [Irrlicht's tutorial](http://irrlicht.sourceforge.net/docu/example001.html) on setting up Visual Studio if you have problems.
80 | * Right click on the name of the project on the Solution Explorer
81 | * Click properties
82 | * Go to the C++ Include Directories tab
83 | * Add the irrlicht include folder to include directories
84 | * Add the irrlicht lib/win32-visualstudio folder to lib directories
85 | * Copy irrlicht/bin/win32-visualstudio/irrlicht.dll to project/debug/irrlicht.dll
86 |
87 | The project should now build correctly. You will need to copy the media folder across to project/debug
88 |
89 |
90 |
91 | Code
92 | ====
93 |
94 | This is outdated info, needs updating.
95 |
96 | * **common**.hpp - general compile settings, includes and defines. Used in every other file.
97 | * **conf_cmake**.hpp.in - defines from cmake.
98 | * **main**.cpp - contains the main() function, starts irrlicht and the editor.
99 | * **Editor**.cpp/hpp - contains the Editor class which contains the update loop.
100 | * **EditorState**.cpp/hpp - contains the EditorState class, which is used to share common variables. Also contains main class for mode FSM.
101 | * **MenuState**.cpp/hpp - contains the MenuState class which handles the user interface such as the menu bar and mode icons.
102 | * **NBEEditor**.cpp/hpp - contains the node box editor mode in the mode FSM.
103 | * **NodeEditor**.cpp/hpp - contains the node editor mode in the mode FSM.
104 | * **Project**.cpp/hpp - holds the project in a contained way.
105 | * **Node**.cpp/hpp - hold the data and node boxes for a single node.
106 | * **NodeBox**.cpp/hpp - a single node box.
107 | * **Configuration**.cpp/hpp - the settings manager for the editor. Reads from / writes to editor.conf
108 | * **GUIHelpers**.cpp/hpp - contains helpers such as creating x/y/z text boxes.
109 | * FileFormat
110 | * **FileFormat**.cpp/hpp - factory and base class for file formats.
111 | * **Lua**.cpp/hpp - the Lua file parser.
112 | * **NBE**.cpp/hpp - the NBE file parser.
113 | * **MTC**.cpp/hpp - the Minetest Classic (.cpp) file parser.
114 | * util
115 | * **string**.cpp/hpp - helper functions for strings
116 |
117 |
--------------------------------------------------------------------------------
/docs/fileformat.md:
--------------------------------------------------------------------------------
1 | NBE File Format
2 | ===============
3 |
4 | The first five bytes tell the parser that it is an NBE file.
5 | "NBEFP"
6 |
7 | The next byte is a number between 1 and 255 which indicates how many files there are.
8 |
9 | Next up is the file table. It is in this format:
10 |
11 | | Length | Description |
12 | |----------|-----------------------------------------|
13 | | 50 bytes | Name of the file |
14 | | 4 bytes | Start position of file data, x bytes in |
15 | | 4 bytes | Size of the file data, x bytes |
16 |
17 | Then comes the file data, one after another.
18 |
--------------------------------------------------------------------------------
/docs/make_install.md:
--------------------------------------------------------------------------------
1 | Make Install
2 | ============
3 |
4 | This document will outline the process of installing the editor onto your system,
5 | and will also give important information in order to avoid common slip ups.
6 |
7 | This is only for Linux operating systems.
8 |
9 | Installing
10 | ----------
11 |
12 | After you compile the editor (see readme, or developers.md), it is as simple as this:
13 |
14 | $ sudo make install
15 |
16 | If you receive any errors, please report them.
17 |
18 | Using Installed Builds
19 | ----------------------
20 |
21 | To run, use $ nodeboxeditor
22 |
23 | * Project, imports and exports will be saved to and read from /home/
.
24 | You can change this with the save_directory setting in editor.conf
25 | * Configuration will be read from /home/.config/nodeboxeditor.conf
first,
26 | and then /usr/local/share/nodeboxeditor/editor.conf if that fails.
27 | * Resources are saved in /usr/local/share/nodeboxeditor
28 | * The executable is in /usr/local/bin
29 | * Textures will be imported and exported to /home/
.
30 |
31 |
--------------------------------------------------------------------------------
/docs/projectfileformat.txt:
--------------------------------------------------------------------------------
1 | # --------------------------------------------------------- #
2 | # FILE FORMAT FOR NBE PROJECT FILES USING PARSER VERSION 1 #
3 | # This is the file format for project.txt in .nbe files #
4 | # Comments ARE NOT allowed in real format #
5 | # Axis Y is height #
6 | # --------------------------------------------------------- #
7 |
8 | MINETEST NODEBOX EDITOR # Tells the parser that this is a .nbe file
9 | PARSER 2 # What version the parser uses. Versions may not be backwards compatible.
10 | NAME my_mod_namespace # The folder the mod should be in
11 |
12 |
13 | # Blank lines are okay
14 |
15 |
16 | # -------------------------------------------------- #
17 | # this is a node block which adds an individual node #
18 | # -------------------------------------------------- #
19 | NODE tree_block # Declares a node, and gives it its name.
20 | POSITION 0 0 0 # position in editor grid
21 | #
22 | NODEBOX name -0.5 -0.5 -0.5 0.5 0.5 0.5 # A single box called name.
23 | NODEBOX name -0.5 -0.5 -0.5 0.5 0.5 0.5 # a single box called name
24 | TEXTURE top mod_top_texture.png # uses textures/mod_top_texture.png for top face
25 | END NODE
26 |
27 |
28 | # Blank line
29 |
30 |
31 | # -------------------------------------------------- #
32 | # this is a node block which adds an individual node #
33 | # -------------------------------------------------- #
34 | NODE tree_block_2 # Declares a node, and gives it its name.
35 | POSITION 1 0 0 # position in editor grid.
36 | #
37 | NODEBOX name -0.5 -0.5 -0.5 0.5 0.5 0.5 # A single box called name.
38 | NODEBOX name -0.5 -0.5 -0.5 0.5 0.5 0.5 # a single box called name
39 | END NODE
40 |
--------------------------------------------------------------------------------
/editor.conf.example:
--------------------------------------------------------------------------------
1 | # In node box editor mode, snapping makes node boxes
2 | # snap to pixels
3 | snapping = true
4 |
5 | # The resolution the nodebox snaps to (can be overriden per node)
6 | default_snap_res = 16
7 |
8 | # limiting stops node boxes going out of node bounds
9 | limiting = true
10 |
11 | # If true, positions in nodebox properties are shown as multiples of 1/16
12 | fractional_positions = false
13 |
14 | # Directory to save projects and export to.
15 | # Should be absolute path.
16 | save_directory =
17 |
18 | # The editor should attempt to find Minetest automatically
19 | # If it fails, enter an absolute path to the minetest root folder, eg:
20 | # c://Games/Minetest/
21 | # /home/rubenwardy/Game/Minetest/
22 | # Do not include bin/minetest or bin/minetest.exe in the root.
23 | minetest_root =
24 |
25 | # The view of each viewport
26 | # can be: pers, front, back, top, bottom, left, right
27 | viewport_top_left = pers
28 | viewport_top_right = top
29 | viewport_bottom_left = front
30 | viewport_bottom_right = right
31 |
32 | # Lighting
33 | # 0: no lighting / shadows
34 | # 1: Depth lighting (things further away from camera are darker) (TODO)
35 | # 2: Normal lighting (like in Minetest)
36 | lighting = 2
37 |
38 | # If true, nodes that are not selected will be hidden
39 | # when not in the node tool
40 | hide_other_nodes = true
41 |
42 | # Move all nodes up when a node is placed at negative y
43 | no_negative_node_y = true
44 |
45 | # Driver used to render
46 | driver = opengl
47 |
48 | # Hide the sidebar
49 | hide_sidebar = false
50 |
51 | # Whether the position draw handle should be shown
52 | always_show_position_handle = false
53 |
54 | # Vertical syncronisation
55 | dont_use_vsync = false
56 |
57 | # Enable this if vsync is not working for you
58 | use_sleep = false
59 |
60 | # Screen settings
61 | fullscreen = false
62 | width = 896
63 | height = 520
64 |
--------------------------------------------------------------------------------
/examples/default_dirt.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rubenwardy/NodeBoxEditor/a5ef5e4c0d07e44f32f088d9a10907fe8b008c73/examples/default_dirt.png
--------------------------------------------------------------------------------
/examples/default_stone.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rubenwardy/NodeBoxEditor/a5ef5e4c0d07e44f32f088d9a10907fe8b008c73/examples/default_stone.png
--------------------------------------------------------------------------------
/examples/wool_blue.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rubenwardy/NodeBoxEditor/a5ef5e4c0d07e44f32f088d9a10907fe8b008c73/examples/wool_blue.png
--------------------------------------------------------------------------------
/examples/wool_green.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rubenwardy/NodeBoxEditor/a5ef5e4c0d07e44f32f088d9a10907fe8b008c73/examples/wool_green.png
--------------------------------------------------------------------------------
/examples/wool_red.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rubenwardy/NodeBoxEditor/a5ef5e4c0d07e44f32f088d9a10907fe8b008c73/examples/wool_red.png
--------------------------------------------------------------------------------
/media/coordinates.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rubenwardy/NodeBoxEditor/a5ef5e4c0d07e44f32f088d9a10907fe8b008c73/media/coordinates.png
--------------------------------------------------------------------------------
/media/flip_x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rubenwardy/NodeBoxEditor/a5ef5e4c0d07e44f32f088d9a10907fe8b008c73/media/flip_x.png
--------------------------------------------------------------------------------
/media/flip_y.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rubenwardy/NodeBoxEditor/a5ef5e4c0d07e44f32f088d9a10907fe8b008c73/media/flip_y.png
--------------------------------------------------------------------------------
/media/flip_z.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rubenwardy/NodeBoxEditor/a5ef5e4c0d07e44f32f088d9a10907fe8b008c73/media/flip_z.png
--------------------------------------------------------------------------------
/media/fontlucida.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rubenwardy/NodeBoxEditor/a5ef5e4c0d07e44f32f088d9a10907fe8b008c73/media/fontlucida.png
--------------------------------------------------------------------------------
/media/gui_scale.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rubenwardy/NodeBoxEditor/a5ef5e4c0d07e44f32f088d9a10907fe8b008c73/media/gui_scale.png
--------------------------------------------------------------------------------
/media/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rubenwardy/NodeBoxEditor/a5ef5e4c0d07e44f32f088d9a10907fe8b008c73/media/icon.png
--------------------------------------------------------------------------------
/media/icon_mode_node.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rubenwardy/NodeBoxEditor/a5ef5e4c0d07e44f32f088d9a10907fe8b008c73/media/icon_mode_node.png
--------------------------------------------------------------------------------
/media/icon_mode_nodebox.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rubenwardy/NodeBoxEditor/a5ef5e4c0d07e44f32f088d9a10907fe8b008c73/media/icon_mode_nodebox.png
--------------------------------------------------------------------------------
/media/icon_mode_texture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rubenwardy/NodeBoxEditor/a5ef5e4c0d07e44f32f088d9a10907fe8b008c73/media/icon_mode_texture.png
--------------------------------------------------------------------------------
/media/rotate_x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rubenwardy/NodeBoxEditor/a5ef5e4c0d07e44f32f088d9a10907fe8b008c73/media/rotate_x.png
--------------------------------------------------------------------------------
/media/rotate_y.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rubenwardy/NodeBoxEditor/a5ef5e4c0d07e44f32f088d9a10907fe8b008c73/media/rotate_y.png
--------------------------------------------------------------------------------
/media/rotate_z.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rubenwardy/NodeBoxEditor/a5ef5e4c0d07e44f32f088d9a10907fe8b008c73/media/rotate_z.png
--------------------------------------------------------------------------------
/media/sky.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rubenwardy/NodeBoxEditor/a5ef5e4c0d07e44f32f088d9a10907fe8b008c73/media/sky.jpg
--------------------------------------------------------------------------------
/media/texture_box.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rubenwardy/NodeBoxEditor/a5ef5e4c0d07e44f32f088d9a10907fe8b008c73/media/texture_box.png
--------------------------------------------------------------------------------
/media/texture_terrain.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rubenwardy/NodeBoxEditor/a5ef5e4c0d07e44f32f088d9a10907fe8b008c73/media/texture_terrain.png
--------------------------------------------------------------------------------
/nodeboxeditor.desktop:
--------------------------------------------------------------------------------
1 | [Desktop Entry]
2 | Name=Node Box Editor
3 | GenericName=Minetest Node Box Editor
4 | Comment=Edit and create node boxes for Minetest
5 | GenericName[fr]=Éditeur de node boxes pour Minetest
6 | Comment[fr]=Créer et éditer des node boxes pour Minetest
7 | Exec=nodeboxeditor
8 | Icon=/usr/local/share/nodeboxeditor/media/icon.png
9 | Terminal=false
10 | Type=Application
11 | Categories=Development;
12 | StartupNotify=false
13 |
--------------------------------------------------------------------------------
/src/Configuration.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include "Configuration.hpp"
5 | #include "util/string.hpp"
6 |
7 |
8 | bool Configuration::load(const std::string & filename){
9 | std::string line;
10 | std::ifstream file(filename.c_str());
11 | if (!file) {
12 | return false;
13 | }
14 | while (std::getline(file, line)) {
15 | readLine(line);
16 | }
17 | file.close();
18 | return true;
19 | }
20 |
21 |
22 | void Configuration::readLine(std::string & line){
23 | // Skip comments
24 | if (line[0] == '#')
25 | return;
26 | line = trim(line);
27 |
28 | if (line.empty()) {
29 | return;
30 | }
31 |
32 | // Split string into hash and value per
33 | size_t eqPos = line.find('=');
34 | if (eqPos == std::string::npos) {
35 | return;
36 | }
37 | const std::string key = trim(line.substr(0, eqPos));
38 | const std::string value = trim(line.substr(eqPos + 1));
39 |
40 | // Create setting
41 | settings[key] = value;
42 | }
43 |
44 |
45 | bool Configuration::save(const std::string & filename){
46 | std::ofstream file(filename.c_str());
47 | if (!file) {
48 | return false;
49 | }
50 | for (std::map::const_iterator it = settings.begin();
51 | it != settings.end();
52 | ++it) {
53 | file << it->first << " = " << it->second << "\n";
54 | }
55 | file.close();
56 | return true;
57 | }
58 |
59 |
60 | const std::string & Configuration::get(const std::string & key) const
61 | {
62 | return settings.find(key)->second;
63 | }
64 |
65 |
66 | void Configuration::set(const std::string & key, const std::string & value)
67 | {
68 | settings[key] = value;
69 | }
70 |
71 |
72 | static inline bool to_bool(const std::string & str)
73 | {
74 | std::string s = str_to_lower(str);
75 | return s == "true" || s == "yes" || s == "1" || s == "on";
76 | }
77 |
78 |
79 | bool Configuration::getBool(const std::string & key) const
80 | {
81 | return to_bool(settings.find(key)->second);
82 | }
83 |
84 |
85 | int Configuration::getInt(const std::string & key) const
86 | {
87 | return atoi(settings.find(key)->second.c_str());
88 | }
89 |
--------------------------------------------------------------------------------
/src/Configuration.hpp:
--------------------------------------------------------------------------------
1 | #ifndef CONFIGURATION_HPP_INCLUDED
2 | #define CONFIGURATION_HPP_INCLUDED
3 |
4 | #include