Some changes & additions. (#2)

* Initial HID implementation.

Not everything may be right. I have to figure out some stuff tho.

* Add a tint param to `Gui::DrawSprite()`.

Also add Universal-Core logo.
This commit is contained in:
StackZ
2020-03-05 04:25:52 +01:00
committed by GitHub
parent c82ad8d6e1
commit eceb6b884d
6 changed files with 147 additions and 3 deletions
+4
View File
@@ -1,5 +1,9 @@
# Universal-Core by Universal-Team
This contains the GUI & Core part for our 3DS Applications.
Logo created by: [TotallyNotGuy](https://github.com/TotallyNotGuy).
![Universal-Core-Logo](https://github.com/Universal-Team/Universal-Core/blob/master/universal-core-logo.png)
Licensing:
This software is licensed under the terms of the GPLv3. You can find a copy of the license in the LICENSE file.
+8 -2
View File
@@ -44,10 +44,16 @@ void Gui::clearTextBufs(void)
}
// Draw a sprite from the sheet.
void Gui::DrawSprite(C2D_SpriteSheet sheet, size_t imgindex, int x, int y, float ScaleX, float ScaleY)
void Gui::DrawSprite(C2D_SpriteSheet sheet, size_t imgindex, int x, int y, float ScaleX, float ScaleY, u32 tintColor)
{
// Tint sprite.
C2D_ImageTint tint;
C2D_SetImageTint(&tint, C2D_TopLeft, tintColor, 1);
C2D_SetImageTint(&tint, C2D_TopRight, tintColor, 1);
C2D_SetImageTint(&tint, C2D_BotLeft, tintColor, 1);
C2D_SetImageTint(&tint, C2D_BotRight, tintColor, 1);
C2D_Image img = C2D_SpriteSheetGetImage(sheet, imgindex);
C2D_DrawImageAt(img, x, y, 0.5f, NULL, ScaleX, ScaleY);
C2D_DrawImageAt(img, x, y, 0.5f, &tint, ScaleX, ScaleY);
}
// Initialize GUI.
+1 -1
View File
@@ -40,7 +40,7 @@ namespace Gui
void clearTextBufs(void);
// Draw a sprite from a sheet.
void DrawSprite(C2D_SpriteSheet sheet, size_t imgindex, int x, int y, float ScaleX = 1, float ScaleY = 1);
void DrawSprite(C2D_SpriteSheet sheet, size_t imgindex, int x, int y, float ScaleX = 1, float ScaleY = 1, u32 tintColor = C2D_Color32(0, 0, 0, 0));
// Initialize the GUI with Citro2D & Citro3D and initialize the Textbuffer.
Result init(void);
+75
View File
@@ -0,0 +1,75 @@
/*
* This file is part of Universal-Core
* Copyright (C) 2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy
*
* 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/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "hid.hpp"
HID::HID(size_t EntryPerPage, size_t EntryAmount) {
maxEntries = EntryAmount;
pageEntry = EntryPerPage;
}
size_t HID::getIndex() {
return currentEntry;
}
size_t HID::getMaxEntries() {
return maxEntries;
}
void HID::nextEntry() {
if (currentEntry < maxEntries-1) {
currentEntry++;
}
}
void HID::lastEntry() {
if (currentEntry > 0) {
currentEntry--;
}
}
void HID::nextPage() {
// Only go to the next page, if the next Page doesn't reach the maxEntries.
if (currentEntry + pageEntry < maxEntries - 1) {
currentPage++;
currentEntry += pageEntry;
// If the first index of the page is smaller than maxEntries -> Go to the next page.
} else if (currentPage * pageEntry < maxEntries - 1) {
currentPage++;
currentEntry = currentPage * pageEntry;
}
}
size_t HID::getPage() {
return currentPage;
}
void HID::prevPage() {
if (currentPage > 0) {
currentPage--;
currentEntry -= pageEntry;
}
}
+59
View File
@@ -0,0 +1,59 @@
/*
* This file is part of Universal-Core
* Copyright (C) 2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy
*
* 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/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef HID_HPP
#define HID_HPP
#include <cstddef>
class HID
{
public:
// The parameters to initialize this class.
HID(size_t EntryPerPage, size_t EntryAmount);
// get the current index.
size_t getIndex();
// get the max amount of the index.
size_t getMaxEntries();
// Go to the next Entry, if maxEntries is not reached.
void nextEntry();
// Go to the last Entry, if 0 is not reached.
void lastEntry();
// Go to the next Page.
void nextPage();
// Go to the previous Page.
void prevPage();
// Get the current page.
size_t getPage();
private:
size_t maxEntries;
size_t currentEntry = 0;
size_t pageEntry;
size_t currentPage = 0;
};
#endif
Binary file not shown.

After

Width:  |  Height:  |  Size: 156 KiB