Changes:
Remove MEMTRACK Flag Replace Draw2 with Render2 Rename sound and font to uppercase Add SMART_CTOR to Image Sprite Sound Port Everything to R2
This commit is contained in:
@ -19,7 +19,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <renderd7/Allocator.hpp>
|
||||
#include <renderd7/DrawV2.hpp>
|
||||
#include <renderd7/Error.hpp>
|
||||
#include <renderd7/FileSystem.hpp>
|
||||
#include <renderd7/Hid.hpp>
|
||||
@ -28,13 +27,12 @@
|
||||
#include <renderd7/Message.hpp>
|
||||
#include <renderd7/Net.hpp>
|
||||
#include <renderd7/Overlays.hpp>
|
||||
#include <renderd7/Sound2.hpp>
|
||||
#include <renderd7/StealConsole.hpp>
|
||||
#include <renderd7/Timer.hpp>
|
||||
#include <renderd7/UI7.hpp>
|
||||
#include <renderd7/global_db.hpp>
|
||||
#include <renderd7/renderd7.hpp>
|
||||
#include <renderd7/sound.hpp>
|
||||
#include <renderd7/swr.hpp>
|
||||
|
||||
namespace RD7 = RenderD7;
|
||||
namespace DV2 = RenderD7::Draw2;
|
||||
namespace RD7 = RenderD7;
|
@ -1,76 +0,0 @@
|
||||
/**
|
||||
* This file is part of RenderD7
|
||||
* Copyright (C) 2021-2024 NPI-D7, tobid7
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <citro2d.h>
|
||||
|
||||
#include <renderd7/Color.hpp>
|
||||
#include <renderd7/Image.hpp>
|
||||
#include <renderd7/R7Vec.hpp>
|
||||
#include <renderd7/font.hpp>
|
||||
|
||||
#define MAKEFLAG(x) (1 << x)
|
||||
|
||||
typedef unsigned int RD7TextFlags;
|
||||
|
||||
enum RD7TextFlags_ {
|
||||
RD7TextFlags_None = 0, //< Align is Left and Other things are disabled
|
||||
RD7TextFlags_AlignRight = MAKEFLAG(0),
|
||||
RD7TextFlags_AlignMid = MAKEFLAG(1),
|
||||
RD7TextFlags_Shaddow = MAKEFLAG(2), // TextBuf Killer lol (doubled Text)
|
||||
RD7TextFlags_Wrap = MAKEFLAG(3),
|
||||
RD7TextFlags_Short = MAKEFLAG(4),
|
||||
RD7TextFlags_Scroll = MAKEFLAG(5),
|
||||
};
|
||||
|
||||
namespace RenderD7 {
|
||||
R7Vec2 GetTextDimensions(const std::string& text);
|
||||
void CustomTextSize(float size);
|
||||
void TextDefaultSize();
|
||||
float TextGetSize();
|
||||
std::string TextShort(const std::string& in, int max_len);
|
||||
// Overrite TextBox Size (by default Screenwidth x Text.h)
|
||||
void TextMaxBox(R7Vec2 size);
|
||||
void TextDefaultBox();
|
||||
void TextFont(Font::Ref fnt);
|
||||
void TextFontRestore();
|
||||
void TextDefaultFont();
|
||||
namespace Draw2 {
|
||||
void Scissor(R7Vec2 pos, R7Vec2 size);
|
||||
void ScissorReset();
|
||||
void Rect(R7Vec2 pos, R7Vec2 size, unsigned int color, int t = 1);
|
||||
void RectFilled(R7Vec2 pos, R7Vec2 size, Color4 colors);
|
||||
void RectFilledSolid(R7Vec2 pos, R7Vec2 size, unsigned int color);
|
||||
// Wrapper of RectFilledSolid
|
||||
inline void RFS(R7Vec2 pos, R7Vec2 size, unsigned int color) {
|
||||
RectFilledSolid(pos, size, color);
|
||||
}
|
||||
void Line(R7Vec2 pos0, R7Vec2 pos1, unsigned int color, int t = 1);
|
||||
void Triangle(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2, Color3 colors);
|
||||
void TriangleSolid(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2, unsigned int color);
|
||||
// Beta and Very unstable
|
||||
void TriangleLined(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2, unsigned int color,
|
||||
int t = 1);
|
||||
void Text(R7Vec2 pos, const std::string& text, RD7TextFlags flags = 0);
|
||||
void TextClr(R7Vec2 pos, const std::string& text, unsigned int color,
|
||||
RD7TextFlags flags = 0);
|
||||
void Image(RenderD7::Image* img, const R7Vec2& pos = R7Vec2(0, 0),
|
||||
const R7Vec2& scale = R7Vec2(1, 1));
|
||||
} // namespace Draw2
|
||||
} // namespace RenderD7
|
@ -1,54 +1,54 @@
|
||||
/**
|
||||
* This file is part of RenderD7
|
||||
* Copyright (C) 2021-2024 NPI-D7, tobid7
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <citro2d.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <memory>
|
||||
#include <renderd7/Error.hpp>
|
||||
#include <renderd7/smart_ctor.hpp>
|
||||
|
||||
namespace RenderD7 {
|
||||
class Font {
|
||||
public:
|
||||
Font() = default;
|
||||
Font(const std::string& path) { Load(path); };
|
||||
~Font() { Unload(); }
|
||||
RD7_SMART_CTOR(Font)
|
||||
|
||||
void Load(const std::string& path) {
|
||||
std::ifstream ft(path, std::ios::in | std::ios::binary);
|
||||
bool io = ft.is_open();
|
||||
ft.close();
|
||||
RenderD7::InlineAssert(io, "File not Found!");
|
||||
fnt = C2D_FontLoad(path.c_str());
|
||||
RenderD7::InlineAssert(fnt, "Font could not be loaded!");
|
||||
}
|
||||
C2D_Font Ptr() { return fnt; }
|
||||
void Unload() {
|
||||
if (!fnt) return;
|
||||
C2D_FontFree(fnt);
|
||||
fnt = nullptr;
|
||||
}
|
||||
|
||||
private:
|
||||
C2D_Font fnt = nullptr;
|
||||
};
|
||||
} // namespace RenderD7
|
||||
/**
|
||||
* This file is part of RenderD7
|
||||
* Copyright (C) 2021-2024 NPI-D7, tobid7
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <citro2d.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <memory>
|
||||
#include <renderd7/Error.hpp>
|
||||
#include <renderd7/smart_ctor.hpp>
|
||||
|
||||
namespace RenderD7 {
|
||||
class Font {
|
||||
public:
|
||||
Font() = default;
|
||||
Font(const std::string& path) { Load(path); };
|
||||
~Font() { Unload(); }
|
||||
RD7_SMART_CTOR(Font)
|
||||
|
||||
void Load(const std::string& path) {
|
||||
std::ifstream ft(path, std::ios::in | std::ios::binary);
|
||||
bool io = ft.is_open();
|
||||
ft.close();
|
||||
RenderD7::InlineAssert(io, "File not Found!");
|
||||
fnt = C2D_FontLoad(path.c_str());
|
||||
RenderD7::InlineAssert(fnt, "Font could not be loaded!");
|
||||
}
|
||||
C2D_Font Ptr() { return fnt; }
|
||||
void Unload() {
|
||||
if (!fnt) return;
|
||||
C2D_FontFree(fnt);
|
||||
fnt = nullptr;
|
||||
}
|
||||
|
||||
private:
|
||||
C2D_Font fnt = nullptr;
|
||||
};
|
||||
} // namespace RenderD7
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include <renderd7/R7Vec.hpp>
|
||||
#include <renderd7/nimg.hpp>
|
||||
#include <renderd7/smart_ctor.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace RenderD7 {
|
||||
@ -30,14 +31,15 @@ class Image {
|
||||
public:
|
||||
Image();
|
||||
~Image();
|
||||
void load(const std::string& path);
|
||||
void from_nimg(const nimg& image);
|
||||
RD7_SMART_CTOR(Image)
|
||||
void Load(const std::string& path);
|
||||
void From_NIMG(const nimg& image);
|
||||
|
||||
C2D_Image get();
|
||||
C2D_Image& get_ref();
|
||||
void set(const C2D_Image& i);
|
||||
R7Vec2 get_size();
|
||||
bool loaded();
|
||||
C2D_Image Get();
|
||||
C2D_Image& GetRef();
|
||||
void Set(const C2D_Image& i);
|
||||
R7Vec2 GetSize();
|
||||
bool Loadet();
|
||||
|
||||
private:
|
||||
void safe_del();
|
||||
|
@ -67,6 +67,7 @@ class Ovl_Metrik : public RenderD7::Ovl {
|
||||
mutable std::string mt_cmd;
|
||||
mutable std::string mt_lfr;
|
||||
mutable std::string mt_tbs;
|
||||
mutable std::string mt_mem;
|
||||
|
||||
// Importand Adresses
|
||||
bool* i_is_enabled;
|
||||
|
@ -20,25 +20,83 @@
|
||||
|
||||
#include <map>
|
||||
#include <renderd7/Color.hpp>
|
||||
#include <renderd7/Font.hpp>
|
||||
#include <renderd7/Font2.hpp>
|
||||
#include <renderd7/R7Vec.hpp>
|
||||
#include <renderd7/smart_ctor.hpp>
|
||||
|
||||
#define MAKEFLAG(x) (1 << x)
|
||||
|
||||
typedef unsigned int RD7TextFlags;
|
||||
|
||||
enum RD7TextFlags_ {
|
||||
RD7TextFlags_None = 0, //< Align is Left and Other things are disabled
|
||||
RD7TextFlags_AlignRight = MAKEFLAG(0),
|
||||
RD7TextFlags_AlignMid = MAKEFLAG(1),
|
||||
RD7TextFlags_Shaddow = MAKEFLAG(2), // TextBuf Killer lol (doubled Text)
|
||||
RD7TextFlags_Wrap = MAKEFLAG(3),
|
||||
RD7TextFlags_Short = MAKEFLAG(4),
|
||||
RD7TextFlags_Scroll = MAKEFLAG(5),
|
||||
};
|
||||
|
||||
enum R2Screen {
|
||||
R2Screen_Bottom,
|
||||
R2Screen_Top,
|
||||
// TopRight,
|
||||
};
|
||||
|
||||
namespace RenderD7 {
|
||||
class R2Base {
|
||||
public:
|
||||
struct R2Cmd {
|
||||
R7Vec2 pos; //< Position
|
||||
R7Vec2 pszs; //< Position or (TextBox) Size
|
||||
R7Vec2 ap; //< Additional Pos
|
||||
unsigned int clr; //< Color
|
||||
bool Screen; //< TopScreen
|
||||
// 0 = skip, 1 = rect, 2 = tri, 3 = text, 4 = image
|
||||
int type; //< Command Type
|
||||
bool lined = false; //< Draw Lined Rect/Tri
|
||||
// Text Specific
|
||||
RD7TextFlags flags; // Text Flags
|
||||
std::string text; // Text
|
||||
};
|
||||
R2Base();
|
||||
~R2Base() = default;
|
||||
void SetFont();
|
||||
RD7_SMART_CTOR(R2Base)
|
||||
|
||||
// Settings
|
||||
void SetFont(Font::Ref fnt);
|
||||
Font::Ref GetFont();
|
||||
void DefaultFont();
|
||||
void DrawNextLined();
|
||||
void OnScreen(R2Screen screen);
|
||||
R2Screen GetCurrentScreen();
|
||||
void SetTextSize(float szs);
|
||||
void DefaultTextSize();
|
||||
float GetTextSize();
|
||||
|
||||
// Processing
|
||||
void Process();
|
||||
R7Vec2 GetTextDimensions(const std::string& text);
|
||||
|
||||
// Draw Functions
|
||||
void AddRect(R7Vec2 pos, R7Vec2 size, RD7Color clr);
|
||||
void AddRect(R7Vec2 pos, R7Vec2 size, unsigned int clr);
|
||||
void AddTriangle(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2, RD7Color clr);
|
||||
void AddTriangle(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2, unsigned int clr);
|
||||
void AddText(R7Vec2 pos, const std::string& text, RD7Color clr,
|
||||
RD7TextFlags flags = 0, R7Vec2 tmb = R7Vec2());
|
||||
void AddText(R7Vec2 pos, const std::string& text, unsigned int clr,
|
||||
RD7TextFlags flags = 0, R7Vec2 tmb = R7Vec2());
|
||||
|
||||
private:
|
||||
const float default_text_size = 0.5f;
|
||||
float text_size = 0.5;
|
||||
Font::Ref font[2];
|
||||
R7Vec2 max_wh;
|
||||
Font::Ref font;
|
||||
std::map<std::string, float> ts;
|
||||
std::map<std::string, int> mln;
|
||||
bool next_lined = false;
|
||||
std::vector<R2Cmd> commands;
|
||||
R2Screen current_screen = R2Screen_Bottom;
|
||||
};
|
||||
} // namespace RenderD7
|
@ -1,49 +1,51 @@
|
||||
/**
|
||||
* This file is part of RenderD7
|
||||
* Copyright (C) 2021-2024 NPI-D7, tobid7
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <3ds.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
/** Sound Class */
|
||||
class sound {
|
||||
public:
|
||||
/// \brief Construct new Soundeffect
|
||||
/// \param path Path to the .wav file
|
||||
/// \param channel the channel 1-23
|
||||
/// \param toloop true:loop the sound, false: don't loop
|
||||
sound(const std::string &path, int channel = 1, bool toloop = false);
|
||||
/// @brief Deconstructor
|
||||
~sound();
|
||||
/// @brief Play the sound
|
||||
void play();
|
||||
/// @brief Stop the sound
|
||||
void stop();
|
||||
|
||||
private:
|
||||
/// \param dataSize Size of the filedata
|
||||
u32 dataSize;
|
||||
/// \param waveBuf For ndsp
|
||||
ndspWaveBuf waveBuf;
|
||||
/// \param data Memmory data of the sound
|
||||
uint8_t *data = NULL;
|
||||
/// \param chnl Channel of the sound
|
||||
int chnl;
|
||||
};
|
||||
/**
|
||||
* This file is part of RenderD7
|
||||
* Copyright (C) 2021-2024 NPI-D7, tobid7
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <3ds.h>
|
||||
|
||||
#include <renderd7/smart_ctor.hpp>
|
||||
#include <string>
|
||||
|
||||
/** Sound Class */
|
||||
class Sound {
|
||||
public:
|
||||
/// \brief Construct new Soundeffect
|
||||
/// \param path Path to the .wav file
|
||||
/// \param channel the channel 1-23
|
||||
/// \param toloop true:loop the sound, false: don't loop
|
||||
Sound(const std::string &path, int channel = 1, bool toloop = false);
|
||||
/// @brief Deconstructor
|
||||
~Sound();
|
||||
RD7_SMART_CTOR(Sound)
|
||||
/// @brief Play the sound
|
||||
void Play();
|
||||
/// @brief Stop the sound
|
||||
void Stop();
|
||||
|
||||
private:
|
||||
/// \param dataSize Size of the filedata
|
||||
u32 dataSize;
|
||||
/// \param waveBuf For ndsp
|
||||
ndspWaveBuf waveBuf;
|
||||
/// \param data Memmory data of the sound
|
||||
uint8_t *data = NULL;
|
||||
/// \param chnl Channel of the sound
|
||||
int chnl;
|
||||
};
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include <renderd7/Image.hpp>
|
||||
#include <renderd7/Sheet.hpp>
|
||||
#include <renderd7/smart_ctor.hpp>
|
||||
|
||||
namespace RenderD7 {
|
||||
/// @brief Sprite Class
|
||||
@ -32,13 +33,14 @@ class Sprite {
|
||||
Sprite() = default;
|
||||
/// \brief Deconstruct Sprite
|
||||
~Sprite() = default;
|
||||
RD7_SMART_CTOR(Sprite)
|
||||
/// \brief Load a Sprite From SpriteSheet
|
||||
/// \param sheet the Sheet to load from.(RenderD7::Sheet)
|
||||
/// \param index the number of the Sprite in the Sheet
|
||||
void FromSheet(RenderD7::Sheet *sheet, size_t index);
|
||||
/// \brief Load a Sprite From SpriteSheet
|
||||
/// \param img the Image to load from.(RenderD7::Image)
|
||||
void FromImage(RenderD7::Image *img);
|
||||
void FromImage(RenderD7::Image::Ref img);
|
||||
/// @brief Draw the Sprite
|
||||
/// @return success ?
|
||||
bool Draw();
|
||||
@ -62,16 +64,21 @@ class Sprite {
|
||||
void Rotate(float speed);
|
||||
/// @brief Get Tje Sprite's Width
|
||||
/// @return Width
|
||||
float getWidth();
|
||||
float GetWidth();
|
||||
/// @brief Get the Sprite's Height
|
||||
/// @return Height
|
||||
float getHeight();
|
||||
float GetHeight();
|
||||
/// @brief Get The Sprite's X Position
|
||||
/// @return X Position
|
||||
float getPosX();
|
||||
float GetPosX();
|
||||
/// @brief Get the Sprite's Y Position
|
||||
/// @return Y Position
|
||||
float getPosY();
|
||||
float GetPosY();
|
||||
R7Vec2 GetSize();
|
||||
R7Vec2 GetPos();
|
||||
void SetPos(R7Vec2 pos);
|
||||
void SetScale(R7Vec2 scale);
|
||||
void SetRotCenter(R7Vec2 percentage);
|
||||
|
||||
private:
|
||||
/// @param tint ImageTint (unused)
|
||||
|
@ -18,8 +18,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <renderd7/DrawV2.hpp>
|
||||
#include <renderd7/Image.hpp>
|
||||
#include <renderd7/R7Vec.hpp>
|
||||
#include <renderd7/Render2.hpp>
|
||||
#include <renderd7/smart_ctor.hpp>
|
||||
|
||||
// UI7: The new RenderD7 UI Standart based on
|
||||
@ -80,7 +81,7 @@ void Label(const std::string &label, RD7TextFlags flags = 0);
|
||||
void Progressbar(float value);
|
||||
/// @brief Draw Image in Menu
|
||||
/// @param img Pointer f.e to RenderD7::Image2
|
||||
void Image(RenderD7::Image *img);
|
||||
void Image(RenderD7::Image::Ref img);
|
||||
void BrowserList(const std::vector<std::string> &entrys, int &selection,
|
||||
RD7TextFlags txtflags = 0, R7Vec2 size = R7Vec2(0, 0),
|
||||
int max_entrys = 13);
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include <renderd7/Memory.hpp>
|
||||
#include <renderd7/Overlays.hpp>
|
||||
#include <renderd7/Ovl.hpp>
|
||||
#include <renderd7/Render2.hpp>
|
||||
#include <renderd7/ResultDecoder.hpp>
|
||||
#include <renderd7/Screen.hpp>
|
||||
#include <renderd7/Sheet.hpp>
|
||||
@ -67,6 +68,8 @@ extern int rd7_max_objects;
|
||||
extern bool rd7_enable_scene_system;
|
||||
|
||||
namespace RenderD7 {
|
||||
// Reference to the New Renderer
|
||||
R2Base::Ref R2();
|
||||
/// @brief Get Deltatime
|
||||
/// @return Deltatime
|
||||
float GetDeltaTime();
|
||||
|
Reference in New Issue
Block a user