-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use boost python to get a C++ struct/class from python. Implement Graphics2Config (temp name) - has resolution and screen number. Populate struct from config.yaml via config.py. Modify game to take resolution and screen values from config.yaml. Deprecates settings app. Note: Need to document new install step - pip3 install pyyaml somewhere. Implement unit tests in configuration.
- Loading branch information
Showing
16 changed files
with
273 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import yaml | ||
import vegastrike_python | ||
|
||
|
||
def get_config(): | ||
with open('config.yaml', 'r') as file: | ||
yaml_file = yaml.safe_load(file) | ||
print(yaml_file) | ||
|
||
graphics = vegastrike_python.GraphicsConfig() | ||
graphics.screen = yaml_file['graphics']['screen'] | ||
graphics.resolution_x = yaml_file['graphics']['resolution_x'] | ||
graphics.resolution_y = yaml_file['graphics']['resolution_y'] | ||
|
||
|
||
return graphics | ||
|
||
|
||
#gfx = get_config() | ||
#print('screen: ', gfx.screen) | ||
#print('x: ', gfx.resolution_x) | ||
#print('y: ', gfx.resolution_y) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
general: | ||
|
||
graphics: | ||
resolution_x: 2560 | ||
resolution_y: 1600 | ||
screen: 0 | ||
|
||
advanced: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include <string> | ||
#include <boost/python.hpp> | ||
#include <boost/filesystem.hpp> | ||
|
||
#include "graphics_config.h" | ||
#include "python_utils.h" | ||
|
||
|
||
|
||
BOOST_PYTHON_MODULE(vegastrike_python) { | ||
boost::python::class_<Graphics2Config>("GraphicsConfig", boost::python::init<>()) | ||
.def_readwrite("screen", &Graphics2Config::screen) | ||
.def_readwrite("resolution_x", &Graphics2Config::resolution_x) | ||
.def_readwrite("resolution_y", &Graphics2Config::resolution_y); | ||
} | ||
|
||
|
||
|
||
Graphics2Config GetGraphics2Config( | ||
const std::string build_path, | ||
const std::string path_string, | ||
const std::string file_name, | ||
const std::string function_name) { | ||
PyObject* object = GetClassFromPython( | ||
build_path, path_string, file_name, function_name); | ||
|
||
|
||
Graphics2Config cfg2 = boost::python::extract<Graphics2Config>(object); | ||
return cfg2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.