From 8aa0799658c273d6a03005c0a95b9b5ffc80e226 Mon Sep 17 00:00:00 2001 From: Frederico Linhares Date: Wed, 31 May 2023 07:26:14 -0300 Subject: fixt Remove YAML from engine * README.markdown: Remove a dependency that no longer exists and add one that was missing. * src/candy_gear.cpp: Remove YAML from the engine as mruby already provides it. * src/sprite_implementation.cpp, src/sprite_implementation.hpp: Remove unused code. --- README.markdown | 2 +- Rakefile | 3 +-- src/candy_gear.cpp | 50 ------------------------------------ src/core.cpp | 2 -- src/sprite_implementation.cpp | 59 ------------------------------------------- src/sprite_implementation.hpp | 41 ------------------------------ 6 files changed, 2 insertions(+), 155 deletions(-) delete mode 100644 src/sprite_implementation.cpp delete mode 100644 src/sprite_implementation.hpp diff --git a/README.markdown b/README.markdown index e2c05db..b9cb3df 100644 --- a/README.markdown +++ b/README.markdown @@ -11,7 +11,7 @@ However, because of this flexibility, the engine presumes that you have some bas Installation ------------ -CandyGear uses the libraries libSDL2, SDL2\_mixer, and yaml-cpp, so before installing CandyGear into a machine, ensure that development libraries for SDL are installed. +CandyGear uses the libraries libSDL2, SDL2\_mixer, and freetype, so before installing CandyGear into a machine, ensure that development libraries for SDL are installed. CandyGear is compiled with Ruby Rake; also ensure it is installed. To compile the code, run `rake` at the root directory; it will generate the binary engine. To install the core, run `rake install`. diff --git a/Rakefile b/Rakefile index 042eac2..838f3ce 100644 --- a/Rakefile +++ b/Rakefile @@ -53,8 +53,7 @@ LIBRARIES = [ 'SDL2', 'SDL2_mixer', 'freetype', - 'm', - 'yaml-cpp' + 'm' ] case OS when :windows diff --git a/src/candy_gear.cpp b/src/candy_gear.cpp index f9c5528..426db4b 100644 --- a/src/candy_gear.cpp +++ b/src/candy_gear.cpp @@ -20,46 +20,10 @@ #include #include -#include - #include "core.hpp" #include "view_2d.hpp" #include "view_3d.hpp" -static mrb_value -parse_node(mrb_state *mrb, const YAML::Node &node) -{ - mrb_value value; - std::string scalar; - - switch(node.Type()) - { - case YAML::NodeType::Null: - return mrb_nil_value(); - - case YAML::NodeType::Scalar: - scalar = node.as(); - return mrb_str_new(mrb, scalar.data(), scalar.size()); - - case YAML::NodeType::Sequence: - value = mrb_ary_new_capa(mrb, node.size()); - for (YAML::const_iterator it = node.begin(); it != node.end(); it++) - mrb_ary_push(mrb, value, parse_node(mrb, *it)); - return value; - - case YAML::NodeType::Map: - value = mrb_hash_new_capa(mrb, node.size()); - for(YAML::const_iterator it = node.begin(); it != node.end(); it++) - mrb_hash_set( - mrb, value, parse_node(mrb, it->first), parse_node(mrb, it->second)); - return value; - - case YAML::NodeType::Undefined: - default: - return mrb_nil_value(); - } -} - static mrb_value cg_mCandyGear_set_game_name(mrb_state *mrb, mrb_value self) { @@ -71,18 +35,6 @@ cg_mCandyGear_set_game_name(mrb_state *mrb, mrb_value self) return self; } -static mrb_value -cg_mCandyGear_load_yaml(mrb_state *mrb, mrb_value self) -{ - const char *file_path; - - mrb_get_args(mrb, "z", &file_path); - - YAML::Node root = YAML::LoadFile(file_path); - - return parse_node(mrb, root); -} - static mrb_value cg_mCandyGear_set_views(mrb_state *mrb, mrb_value self) { @@ -185,8 +137,6 @@ cg_candy_gear_init(mrb_state *mrb) cg_m = mrb_module_get(mrb, "CandyGear"); - mrb_define_class_method( - mrb, cg_m, "load_yaml", cg_mCandyGear_load_yaml, MRB_ARGS_REQ(1)); mrb_define_class_method( mrb, cg_m, "views=", cg_mCandyGear_set_views, MRB_ARGS_REQ(1)); mrb_define_class_method( diff --git a/src/core.cpp b/src/core.cpp index d87bbe9..5039ffe 100644 --- a/src/core.cpp +++ b/src/core.cpp @@ -35,8 +35,6 @@ #include #endif -#include - std::random_device random_seed; std::mt19937 random_number_generator; diff --git a/src/sprite_implementation.cpp b/src/sprite_implementation.cpp deleted file mode 100644 index caa56a2..0000000 --- a/src/sprite_implementation.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2022 Frederico de Oliveira Linhares - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "sprite_implementation.hpp" - -#include -#include - -#include - -bool -cg_SpriteArray_constructor( - struct cg_SpriteArray_s *self, const char *file_path) -{ - YAML::Node root = YAML::LoadFile(file_path); - self->len = root.size(); - self->sprites = new cg_Sprite_s[self->len]; - - int index = 0; - for(YAML::const_iterator sprite_node = root.begin(); - sprite_node != root.end(); - sprite_node++) - { - cg_Sprite_s *sprite = &self->sprites[index]; - - auto node_name = sprite_node->first.as(); - sprite->name = new char[node_name.size() + 1]; - strcpy(sprite->name, node_name.c_str()); - - sprite->x = sprite_node->second["x"].as(); - sprite->y = sprite_node->second["y"].as(); - sprite->width = sprite_node->second["width"].as(); - sprite->height = sprite_node->second["height"].as(); - - index++; - } - - return true; -} - -void -cg_SpriteArray_destructor(struct cg_SpriteArray_s *self) -{ - for(auto i = 0; i < self->len; i++) delete[] self->sprites[i].name; - delete[] self->sprites; -} diff --git a/src/sprite_implementation.hpp b/src/sprite_implementation.hpp deleted file mode 100644 index d679272..0000000 --- a/src/sprite_implementation.hpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2022 Frederico de Oliveira Linhares - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef CANDY_GEAR_SPRITE_IMPLEMENTATION_H -#define CANDY_GEAR_SPRITE_IMPLEMENTATION_H 1 - -#include - -struct cg_Sprite_s -{ - char *name; - int32_t x, y, width, height; -}; - -struct cg_SpriteArray_s -{ - int32_t len; - struct cg_Sprite_s *sprites; -}; - -bool -cg_SpriteArray_constructor( - struct cg_SpriteArray_s *self, const char *file_path); - -void -cg_SpriteArray_destructor(struct cg_SpriteArray_s *self); - -#endif /* CANDY_GEAR_SPRITE_IMPLEMENTATION_H */ -- cgit v1.2.3