mirror of
https://github.com/J-D-K/JKSV.git
synced 2026-03-21 17:24:37 -05:00
Add FadeIn on boot, change FileOptionState transition type, UI tweaks.
This commit is contained in:
parent
fb88c7939a
commit
c677189452
|
|
@ -6,7 +6,7 @@ import os
|
|||
import sys
|
||||
import shutil
|
||||
|
||||
def main():
|
||||
def main() -> int:
|
||||
# This is run from the makefile. All paths must be relative to it, not the script.
|
||||
inputDir: str = "./Text/Files"
|
||||
outputDir: str = "./romfs/Text"
|
||||
|
|
@ -18,27 +18,22 @@ def main():
|
|||
|
||||
for entry in os.listdir(inputDir):
|
||||
|
||||
inputPath: str = f"{inputDir}/{entry}";
|
||||
inputPath: str = f"{inputDir}/{entry}"
|
||||
inputSize: int = os.path.getsize(inputPath)
|
||||
inputFile: object = open(file=inputPath, mode="rb")
|
||||
if inputFile.closed:
|
||||
print(f"Error opening {inputPath} for reading!")
|
||||
continue
|
||||
with open(file=inputPath, mode="rb") as inputFile:
|
||||
|
||||
inputBuffer: bytes = inputFile.read(inputSize)
|
||||
outputBuffer: bytes = zlib.compress(inputBuffer, 9)
|
||||
inputBuffer: bytes = inputFile.read()
|
||||
outputBuffer: bytes = zlib.compress(inputBuffer, 9)
|
||||
|
||||
outputPath: str = f"{outputDir}/{entry}.z"
|
||||
outputFile: object = open(file=outputPath, mode="wb")
|
||||
if outputFile.closed:
|
||||
print("Error opening {outputPath} for writing!")
|
||||
continue
|
||||
outputPath: str = f"{outputDir}/{entry}.z"
|
||||
with open(file=outputPath, mode="wb") as outputFile:
|
||||
|
||||
inputSizeBytes: bytes = inputSize.to_bytes(4, byteorder="little")
|
||||
outputSizeBytes: bytes = len(outputBuffer).to_bytes(4, byteorder="little")
|
||||
outputFile.write(inputSizeBytes)
|
||||
outputFile.write(outputSizeBytes)
|
||||
outputFile.write(outputBuffer)
|
||||
inputSizeBytes: bytes = inputSize.to_bytes(4, byteorder="little")
|
||||
outputSizeBytes: bytes = len(outputBuffer).to_bytes(4, byteorder="little")
|
||||
|
||||
outputFile.write(inputSizeBytes)
|
||||
outputFile.write(outputSizeBytes)
|
||||
outputFile.write(outputBuffer)
|
||||
|
||||
return 0
|
||||
|
||||
|
|
|
|||
|
|
@ -1,52 +0,0 @@
|
|||
#pragma once
|
||||
#include <json-c/json.h>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace json
|
||||
{
|
||||
// Use this instead of default json_object
|
||||
using Object = std::unique_ptr<json_object, decltype(&json_object_put)>;
|
||||
|
||||
// Use this instead of json_object_from_x. Pass the function and its arguments instead.
|
||||
template <typename... Args>
|
||||
static inline json::Object new_object(json_object *(*function)(Args...), Args... args)
|
||||
{
|
||||
return json::Object((*function)(args...), json_object_put);
|
||||
}
|
||||
|
||||
/// @brief Inline wrapper function for getting a json object by it's key.
|
||||
/// @param json json::Object to get the key from.
|
||||
/// @param key Key to get.
|
||||
/// @return json_object on success. NULL on failure.
|
||||
static inline json_object *get_object(json::Object &json, std::string_view key)
|
||||
{
|
||||
return json_object_object_get(json.get(), key.data());
|
||||
}
|
||||
|
||||
/// @brief Inline wrapper function to add an object to a json_object
|
||||
/// @param json Json object to add an object to.
|
||||
/// @param key Key of the object.
|
||||
/// @param object Object to add to json.
|
||||
/// @return True on success. False on failure.
|
||||
static inline bool add_object(json::Object &json, std::string_view key, json_object *object)
|
||||
{
|
||||
return json_object_object_add(json.get(), key.data(), object) == 0;
|
||||
}
|
||||
|
||||
/// @brief Returns the json string.
|
||||
static inline const char *get_string(json::Object &json) { return json_object_get_string(json.get()); }
|
||||
|
||||
/// @brief Returns the length of the string. I find json_object_get_string_len is unreliable?
|
||||
static inline int64_t length(json::Object &json)
|
||||
{
|
||||
const char *string = json_object_get_string(json.get());
|
||||
return std::char_traits<char>::length(string);
|
||||
}
|
||||
|
||||
/// @brief Returns the beginning for iterating.
|
||||
static inline json_object_iterator iter_begin(json::Object &json) { return json_object_iter_begin(json.get()); }
|
||||
|
||||
/// @brief Returns the end for iterating.
|
||||
static inline json_object_iterator iter_end(json::Object &json) { return json_object_iter_end(json.get()); }
|
||||
} // namespace json
|
||||
|
|
@ -40,6 +40,9 @@ class DataLoadingState final : public BaseTask
|
|||
/// @brief Update override.
|
||||
void update() override;
|
||||
|
||||
/// @brief Updates the loading glyph.
|
||||
void sub_update() override;
|
||||
|
||||
/// @brief Render override.
|
||||
void render() override;
|
||||
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@ JKSV::JKSV()
|
|||
sys::threadpool::initialize();
|
||||
|
||||
data::launch_initialization(false, finish_initialization);
|
||||
FadeState::create_and_push(colors::BLACK, 0xFF, 0x00, nullptr);
|
||||
|
||||
sm_isRunning = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ void DataLoadingState::update()
|
|||
m_context.process_icon_queue();
|
||||
}
|
||||
|
||||
void DataLoadingState::sub_update() { BaseTask::update_loading_glyph(); }
|
||||
|
||||
void DataLoadingState::render()
|
||||
{
|
||||
static constexpr int ICON_X_COORD = SCREEN_CENTER - 128;
|
||||
|
|
|
|||
|
|
@ -30,6 +30,10 @@ namespace
|
|||
PROPERTIES,
|
||||
CLOSE
|
||||
};
|
||||
|
||||
constexpr int LEFT_X = 200;
|
||||
constexpr int RIGHT_X = 840;
|
||||
constexpr int TOP_Y = 218;
|
||||
}
|
||||
|
||||
// Defined at bottom.
|
||||
|
|
@ -38,7 +42,7 @@ static std::string get_size_string(int64_t totalSize);
|
|||
FileOptionState::FileOptionState(FileModeState *spawningState)
|
||||
: m_spawningState(spawningState)
|
||||
, m_target(spawningState->m_target)
|
||||
, m_transition(m_target ? 1280 : -240, 218, 0, 0, m_target ? 840 : 200, 218, 0, 0, 4)
|
||||
, m_transition(m_target ? RIGHT_X : LEFT_X, 232, 32, 32, m_target ? RIGHT_X : LEFT_X, 232, 256, 256, 4)
|
||||
, m_dataStruct(std::make_shared<FileOptionState::DataStruct>())
|
||||
{
|
||||
FileOptionState::initialize_static_members();
|
||||
|
|
@ -48,13 +52,16 @@ FileOptionState::FileOptionState(FileModeState *spawningState)
|
|||
void FileOptionState::update()
|
||||
{
|
||||
m_transition.update();
|
||||
if (!m_transition.in_place())
|
||||
{
|
||||
const int x = m_transition.get_x();
|
||||
sm_dialog->set_x(x);
|
||||
sm_copyMenu->set_x(x + 9);
|
||||
return;
|
||||
}
|
||||
const int width = m_transition.get_width();
|
||||
const int height = m_transition.get_height();
|
||||
int x = m_transition.get_x();
|
||||
x += 128 - (width / 2);
|
||||
int y = m_transition.get_centered_y();
|
||||
sm_dialog->set_x(x);
|
||||
sm_dialog->set_y(y);
|
||||
sm_dialog->set_width(width);
|
||||
sm_dialog->set_height(height);
|
||||
if (!m_transition.in_place()) { return; }
|
||||
|
||||
const bool hasFocus = BaseState::has_focus();
|
||||
if (m_updateSource)
|
||||
|
|
@ -92,8 +99,9 @@ void FileOptionState::update()
|
|||
void FileOptionState::render()
|
||||
{
|
||||
const bool hasFocus = BaseState::has_focus();
|
||||
|
||||
sm_dialog->render(sdl::Texture::Null, hasFocus);
|
||||
if (!m_transition.in_place()) { return; }
|
||||
|
||||
sm_copyMenu->render(sdl::Texture::Null, hasFocus);
|
||||
}
|
||||
|
||||
|
|
@ -105,15 +113,15 @@ void FileOptionState::initialize_static_members()
|
|||
{
|
||||
if (sm_copyMenu && sm_dialog)
|
||||
{
|
||||
const int x = m_transition.get_x();
|
||||
|
||||
sm_dialog->set_x(x);
|
||||
const int x = m_transition.get_x();
|
||||
const int dialogX = x + (128 - 16);
|
||||
sm_dialog->set_x(dialogX);
|
||||
sm_copyMenu->set_x(x + 9);
|
||||
return;
|
||||
}
|
||||
|
||||
sm_copyMenu = ui::Menu::create(1280, 236, 234, 20, 720); // High target height is a workaround.
|
||||
sm_dialog = ui::DialogBox::create(1280, 218, 256, 256);
|
||||
sm_copyMenu = ui::Menu::create(m_target ? RIGHT_X + 9 : LEFT_X + 9, 253, 234, 20, 720); // Target height is a workaround.
|
||||
sm_dialog = ui::DialogBox::create(2000, 1000, 32, 32); // Create this off screen at first.
|
||||
|
||||
// This never changes, so...
|
||||
for (int i = 0; const char *menuOption = strings::get_by_name(strings::names::FILEOPTION_MENU, i); i++)
|
||||
|
|
@ -331,9 +339,7 @@ void FileOptionState::get_show_target_properties()
|
|||
|
||||
const bool isDir = fslib::directory_exists(targetPath);
|
||||
if (isDir) { FileOptionState::get_show_directory_properties(targetPath); }
|
||||
else {
|
||||
FileOptionState::get_show_file_properties(targetPath);
|
||||
}
|
||||
else { FileOptionState::get_show_file_properties(targetPath); }
|
||||
}
|
||||
|
||||
void FileOptionState::get_show_directory_properties(const fslib::Path &path)
|
||||
|
|
@ -403,9 +409,9 @@ void FileOptionState::pop_system_error()
|
|||
|
||||
void FileOptionState::close()
|
||||
{
|
||||
m_close = true;
|
||||
const int targetX = m_target ? 1280 : -240;
|
||||
m_transition.set_target_x(targetX);
|
||||
m_close = true;
|
||||
m_transition.set_target_width(32);
|
||||
m_transition.set_target_height(32);
|
||||
}
|
||||
|
||||
bool FileOptionState::is_closed() { return m_close && m_transition.in_place(); }
|
||||
|
|
@ -434,7 +440,8 @@ static std::string get_size_string(int64_t totalSize)
|
|||
const double kilobytes = static_cast<double>(totalSize) / static_cast<double>(THRESHOLD_BYTES);
|
||||
sizeString = stringutil::get_formatted_string("%.02f KB", kilobytes);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
const double megabytes = static_cast<double>(totalSize) / static_cast<double>(THRESHOLD_KB);
|
||||
sizeString = stringutil::get_formatted_string("%.02f MB", megabytes);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,13 +12,13 @@
|
|||
|
||||
namespace
|
||||
{
|
||||
constexpr int COORD_BAR_X = 312;
|
||||
constexpr int COORD_BAR_X = 296;
|
||||
constexpr int COORD_BAR_Y = 437;
|
||||
|
||||
constexpr int COORD_TEXT_Y = 442;
|
||||
|
||||
constexpr int COORD_DISPLAY_CENTER = 640;
|
||||
constexpr double SIZE_BAR_WIDTH = 656.0f;
|
||||
constexpr double SIZE_BAR_WIDTH = 688.0f;
|
||||
}
|
||||
|
||||
ProgressState::ProgressState(sys::threadpool::JobFunction function, sys::Task::TaskData taskData)
|
||||
|
|
|
|||
|
|
@ -10,8 +10,11 @@ bool keyboard::get_input(SwkbdType keyboardType,
|
|||
char *stringOut,
|
||||
size_t stringLength)
|
||||
{
|
||||
SwkbdConfig keyboard;
|
||||
swkbdCreate(&keyboard, 0);
|
||||
SwkbdConfig keyboard{};
|
||||
|
||||
const bool createError = error::libnx(swkbdCreate(&keyboard, 0));
|
||||
if (createError) { return false; }
|
||||
|
||||
swkbdConfigSetBlurBackground(&keyboard, true);
|
||||
swkbdConfigSetInitialText(&keyboard, defaultText.data());
|
||||
swkbdConfigSetHeaderText(&keyboard, header.data());
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user