mirror of https://github.com/sm64pc/sm64pc.git
Add new eye texture system, moved colorcode directory
This commit is contained in:
parent
64f951b35e
commit
e7af2fa759
Binary file not shown.
Before Width: | Height: | Size: 35 KiB |
|
@ -1,18 +0,0 @@
|
|||
IDI_ICON1 ICON DISCARDABLE "icon.ico"
|
||||
1 VERSIONINFO
|
||||
FILEVERSION 1,0,0,0
|
||||
PRODUCTVERSION 1,0,0,0
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904E4"
|
||||
BEGIN
|
||||
VALUE "InternalName", "v64saturn"
|
||||
VALUE "ProductName", "Saturn"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 0
|
||||
END
|
||||
END
|
|
@ -14,6 +14,7 @@
|
|||
#include "moon/mod-engine/engine.h"
|
||||
#include "moon/saturn/saturn.h"
|
||||
#include "moon/saturn/saturn_colors.h"
|
||||
#include "moon/saturn/saturn_textures.h"
|
||||
#include "moon/saturn/saturn_types.h"
|
||||
#include "icons/IconsForkAwesome.h"
|
||||
#include "icons/IconsMaterialDesign.h"
|
||||
|
@ -158,6 +159,8 @@ namespace MoonInternal {
|
|||
int tempXRes;
|
||||
int tempYRes;
|
||||
|
||||
int selected_eye_item = 0;
|
||||
|
||||
void setupFonts() {
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
// for (auto entry = Moon::fonts.begin(); entry != Moon::fonts.end(); entry++){
|
||||
|
@ -325,7 +328,7 @@ namespace MoonInternal {
|
|||
ImGui::MenuItem("Stats", NULL, &configImGui.moon64);
|
||||
ImGui::MenuItem("Machinima", NULL, &configImGui.s_machinima);
|
||||
ImGui::MenuItem("Quick Toggles", NULL, &configImGui.s_toggles);
|
||||
ImGui::MenuItem("CC Editor", NULL, &configImGui.s_cceditor);
|
||||
ImGui::MenuItem("Appearance", NULL, &configImGui.s_appearance);
|
||||
//ImGui::MenuItem("Debug Textures", NULL, &configImGui.texture_debug);
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
@ -401,6 +404,8 @@ namespace MoonInternal {
|
|||
ImGui::TableNextColumn();
|
||||
ImGui::Checkbox("HUD", &configHUD);
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Checkbox("M Cap Logo", &enable_cap_logo);
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Checkbox("Head Rotations", &enable_head_rotations);
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Checkbox("Shadows", &enable_shadows);
|
||||
|
@ -409,6 +414,13 @@ namespace MoonInternal {
|
|||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
ImGui::Dummy(ImVec2(0, 5));
|
||||
|
||||
const char* handStates[] = { "Fists", "Open", "Peace", "With Cap", "With Wing Cap", "Right Open" };
|
||||
ImGui::Combo("Hands", ¤t_hand_state, handStates, IM_ARRAYSIZE(handStates));
|
||||
const char* capStates[] = { "Cap On", "Cap Off", "Wing Cap" }; // unused "wing cap off" not included
|
||||
ImGui::Combo("Cap", ¤t_cap_state, capStates, IM_ARRAYSIZE(capStates));
|
||||
|
||||
ImGui::End();
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
|
@ -424,13 +436,39 @@ namespace MoonInternal {
|
|||
|
||||
ImGui::Dummy(ImVec2(0, 10));
|
||||
|
||||
ImGui::Text("Body States");
|
||||
const char* eyeStates[] = { "Default", "Open", "Half", "Closed", "Left", "Right", "Up", "Down", "Dead" };
|
||||
ImGui::Combo("Eyes", ¤t_eye_state, eyeStates, IM_ARRAYSIZE(eyeStates));
|
||||
const char* handStates[] = { "Fists", "Open", "Peace", "With Cap", "With Wing Cap", "Right Open" };
|
||||
ImGui::Combo("Hands", ¤t_hand_state, handStates, IM_ARRAYSIZE(handStates));
|
||||
const char* capStates[] = { "Cap On", "Cap Off", "Wing Cap" }; // unused "wing cap off" not included
|
||||
ImGui::Combo("Cap", ¤t_cap_state, capStates, IM_ARRAYSIZE(capStates));
|
||||
ImGui::Text("Eye State");
|
||||
const char* eyeStates[] = { "Default", "Open", "Half", "Closed", "Custom...", "Dead" };
|
||||
ImGui::Combo("Eyes", &selected_eye_item, eyeStates, IM_ARRAYSIZE(eyeStates));
|
||||
if (selected_eye_item == 0) current_eye_state = 0;
|
||||
if (selected_eye_item == 1) current_eye_state = 1;
|
||||
if (selected_eye_item == 2) current_eye_state = 2;
|
||||
if (selected_eye_item == 3) current_eye_state = 3;
|
||||
if (selected_eye_item == 5) current_eye_state = 8; // dead
|
||||
if (selected_eye_item == 4) {
|
||||
current_eye_state = 4;
|
||||
static int current_eye_id = 0;
|
||||
string eye_name = eye_array[current_eye_id];
|
||||
if (ImGui::BeginCombo(".png", eye_name.c_str()))
|
||||
{
|
||||
for (int o = 0; o < eye_array.size(); o++)
|
||||
{
|
||||
const bool is_eye_selected = (current_eye_id == o);
|
||||
eye_name = eye_array[o];
|
||||
if (ImGui::Selectable(eye_name.c_str(), is_eye_selected)) {
|
||||
current_eye_id = o;
|
||||
}
|
||||
|
||||
// Set the initial focus when opening the combo (scrolling + keyboard navigation focus)
|
||||
if (is_eye_selected)
|
||||
ImGui::SetItemDefaultFocus();
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
if (ImGui::Button("Load")) {
|
||||
custom_eye_name = "eyes/" + eye_array[current_eye_id];
|
||||
saturn_eye_swap();
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::Dummy(ImVec2(0, 10));
|
||||
|
||||
|
@ -480,9 +518,9 @@ namespace MoonInternal {
|
|||
ImGui::End();
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
if (configImGui.s_cceditor && show_menu_bar) {
|
||||
if (configImGui.s_appearance && show_menu_bar) {
|
||||
ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0, 0, 0, 0));
|
||||
ImGui::Begin("CC Editor", NULL, ImGuiWindowFlags_None);
|
||||
ImGui::Begin("Appearance", NULL, ImGuiWindowFlags_None);
|
||||
|
||||
ImGui::Text("Shirt/Cap");
|
||||
ImGui::ColorEdit4("Hat Main", (float*)&uiHatColor, ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_InputRGB | ImGuiColorEditFlags_Uint8 | ImGuiColorEditFlags_NoLabel);
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "pc/configfile.h"
|
||||
|
||||
#include "saturn_colors.h"
|
||||
#include "saturn_textures.h"
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
|
@ -33,6 +34,11 @@ bool enable_dust_particles;
|
|||
bool show_menu_bar;
|
||||
|
||||
float camera_speed = 0.0f;
|
||||
bool enable_cap_logo;
|
||||
|
||||
// Second Check
|
||||
|
||||
bool has_changed_cap_logo;
|
||||
|
||||
namespace MoonInternal {
|
||||
|
||||
|
@ -59,6 +65,12 @@ namespace MoonInternal {
|
|||
show_menu_bar = false;
|
||||
|
||||
MoonInternal::load_cc_directory();
|
||||
|
||||
// custom textures
|
||||
saturn_load_eye_array();
|
||||
custom_eye_name = "eyes/" + eye_array[0];
|
||||
saturn_eye_swap();
|
||||
saturn_toggle_m_cap();
|
||||
}});
|
||||
|
||||
Moon::registerHookListener({.hookName = WINDOW_API_HANDLE_EVENTS, .callback = [&](HookCall call){
|
||||
|
@ -69,10 +81,10 @@ namespace MoonInternal {
|
|||
freeze_camera();
|
||||
}
|
||||
if(ev->key.keysym.sym == SDLK_x){
|
||||
cycle_eye_state(1);
|
||||
//cycle_eye_state(1);
|
||||
}
|
||||
if(ev->key.keysym.sym == SDLK_z){
|
||||
cycle_eye_state(-1);
|
||||
//cycle_eye_state(-1);
|
||||
}
|
||||
if(ev->key.keysym.sym == SDLK_F1){
|
||||
show_menu_bar = !show_menu_bar;
|
||||
|
@ -82,10 +94,10 @@ namespace MoonInternal {
|
|||
freeze_camera();
|
||||
}
|
||||
if (ev->cbutton.button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT) {
|
||||
cycle_eye_state(1);
|
||||
//cycle_eye_state(1);
|
||||
}
|
||||
if (ev->cbutton.button == SDL_CONTROLLER_BUTTON_DPAD_LEFT) {
|
||||
cycle_eye_state(-1);
|
||||
//cycle_eye_state(-1);
|
||||
}
|
||||
if(ev->cbutton.button == SDL_CONTROLLER_BUTTON_BACK){
|
||||
show_menu_bar = !show_menu_bar;
|
||||
|
@ -109,20 +121,15 @@ namespace MoonInternal {
|
|||
gCameraMovementFlags &= ~CAM_MOVE_FIX_IN_PLACE;
|
||||
}
|
||||
|
||||
// Body States
|
||||
// Custom Textures
|
||||
|
||||
if (current_cap_state >= 3) {
|
||||
current_cap_state = 0;
|
||||
if (enable_cap_logo && !has_changed_cap_logo) {
|
||||
saturn_toggle_m_cap();
|
||||
has_changed_cap_logo = true;
|
||||
}
|
||||
|
||||
if (current_eye_state >= 9) {
|
||||
current_eye_state = 0;
|
||||
} else if (current_eye_state <= -1) {
|
||||
current_eye_state = 8;
|
||||
}
|
||||
|
||||
if (current_hand_state >= 6) {
|
||||
current_hand_state = 0;
|
||||
if (!enable_cap_logo && has_changed_cap_logo) {
|
||||
saturn_toggle_m_cap();
|
||||
has_changed_cap_logo = false;
|
||||
}
|
||||
}});
|
||||
}
|
||||
|
|
|
@ -15,5 +15,6 @@ extern bool camera_frozen;
|
|||
extern bool show_menu_bar;
|
||||
|
||||
extern float camera_speed;
|
||||
extern bool enable_cap_logo;
|
||||
|
||||
#endif
|
|
@ -83,9 +83,9 @@ namespace MoonInternal {
|
|||
string cwd = MoonInternal::getEnvironmentVar("MOON_CWD");
|
||||
#ifdef __MINGW32__
|
||||
// Windows moment
|
||||
colorCodeDir = cwd.substr(0, cwd.find_last_of("/\\")) + "\\machinima\\colorcodes\\";
|
||||
colorCodeDir = cwd.substr(0, cwd.find_last_of("/\\")) + "\\addons\\saturn\\assets\\colorcodes\\";
|
||||
#else
|
||||
colorCodeDir = cwd.substr(0, cwd.find_last_of("/\\")) + "/machinima/colorcodes/";
|
||||
colorCodeDir = cwd.substr(0, cwd.find_last_of("/\\")) + "/addons/saturn/assets/colorcodes/";
|
||||
#endif
|
||||
|
||||
for (const auto & entry : fs::directory_iterator(colorCodeDir))
|
||||
|
@ -334,9 +334,9 @@ namespace MoonInternal {
|
|||
//std::cout << gameshark << std::endl;
|
||||
|
||||
#ifdef __MINGW32__
|
||||
std::ofstream file("machinima\\colorcodes\\" + name + ".gs");
|
||||
std::ofstream file("addons\\saturn\\assets\\colorcodes\\" + name + ".gs");
|
||||
#else
|
||||
std::ofstream file("machinima/colorcodes/" + name + ".gs");
|
||||
std::ofstream file("addons/saturn/assets/colorcodes/" + name + ".gs");
|
||||
#endif
|
||||
file << gameshark;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
#include "saturn_textures.h"
|
||||
#include "saturn.h"
|
||||
#include "moon/mod-engine/hooks/hook.h"
|
||||
|
||||
#include "moon/utils/moon-env.h"
|
||||
#include "moon/fs/moonfs.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
#include <dirent.h>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
extern "C" {
|
||||
#include "moon/utils/moon-gfx.h"
|
||||
#include "game/mario.h"
|
||||
}
|
||||
|
||||
string custom_eye_name;
|
||||
|
||||
std::vector<string> eye_array;
|
||||
string eyeDir;
|
||||
|
||||
// Textures
|
||||
|
||||
void saturn_eye_swap() {
|
||||
Moon::registerHookListener({.hookName = TEXTURE_BIND, .callback = [](HookCall call) {
|
||||
char* *hookTexture = reinterpret_cast<char**>(call.baseArgs["texture"]);
|
||||
string texName = string(*hookTexture);
|
||||
if(texName == "actors/mario/mario_eyes_left_unused.rgba16")
|
||||
(*hookTexture) = const_cast<char*>(custom_eye_name.c_str());
|
||||
}});
|
||||
}
|
||||
|
||||
void saturn_load_eye_array() {
|
||||
eye_array.clear();
|
||||
|
||||
string cwd = MoonInternal::getEnvironmentVar("MOON_CWD");
|
||||
#ifdef __MINGW32__
|
||||
// Windows moment
|
||||
eyeDir = cwd.substr(0, cwd.find_last_of("/\\")) + "\\addons\\saturn\\assets\\graphics\\eyes\\";
|
||||
#else
|
||||
eyeDir = cwd.substr(0, cwd.find_last_of("/\\")) + "/addons/saturn/assets/graphics/eyes/";
|
||||
#endif
|
||||
|
||||
for (const auto & entry : fs::directory_iterator(eyeDir)) {
|
||||
size_t last_index = entry.path().filename().u8string().find_last_of(".");
|
||||
string stripped_name = entry.path().filename().u8string().substr(0, last_index);
|
||||
eye_array.push_back(stripped_name);
|
||||
}
|
||||
}
|
||||
|
||||
void saturn_toggle_m_cap() {
|
||||
Moon::registerHookListener({.hookName = TEXTURE_BIND, .callback = [](HookCall call) {
|
||||
char* *hookTexture = reinterpret_cast<char**>(call.baseArgs["texture"]);
|
||||
string texName = string(*hookTexture);
|
||||
if(texName == "actors/mario/mario_logo.rgba16") {
|
||||
if (enable_cap_logo) {
|
||||
(*hookTexture) = const_cast<char*>("actors/mario/mario_logo.rgba16");
|
||||
} else {
|
||||
(*hookTexture) = const_cast<char*>("blank");
|
||||
}
|
||||
}
|
||||
}});
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
#ifndef SaturnTextures
|
||||
#define SaturnTextures
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
extern std::string custom_eye_name;
|
||||
|
||||
extern std::vector<std::string> eye_array;
|
||||
|
||||
void saturn_eye_swap(void);
|
||||
void saturn_load_eye_array(void);
|
||||
void saturn_toggle_m_cap(void);
|
||||
|
||||
#endif
|
|
@ -60,7 +60,7 @@ ImGuiConfig configImGui = {
|
|||
.texture_debug = false,
|
||||
.s_toggles = false,
|
||||
.s_machinima = false,
|
||||
.s_cceditor = false,
|
||||
.s_appearance = false,
|
||||
.s_options = false,
|
||||
.n64Mode = false
|
||||
};
|
||||
|
@ -183,7 +183,7 @@ static const struct ConfigOption options[] = {
|
|||
{.name = "texture_debug_win", .type = CONFIG_TYPE_BOOL, .boolValue = &configImGui.texture_debug},
|
||||
{.name = "s_toggles_win", .type = CONFIG_TYPE_BOOL, .boolValue = &configImGui.s_toggles},
|
||||
{.name = "s_machinima", .type = CONFIG_TYPE_BOOL, .boolValue = &configImGui.s_machinima},
|
||||
{.name = "s_cceditor_win", .type = CONFIG_TYPE_BOOL, .boolValue = &configImGui.s_cceditor},
|
||||
{.name = "s_appearance_win", .type = CONFIG_TYPE_BOOL, .boolValue = &configImGui.s_appearance},
|
||||
{.name = "s_options_win", .type = CONFIG_TYPE_BOOL, .boolValue = &configImGui.s_options},
|
||||
{.name = "n64Mode", .type = CONFIG_TYPE_BOOL, .boolValue = &configImGui.n64Mode}
|
||||
};
|
||||
|
|
|
@ -25,7 +25,7 @@ typedef struct {
|
|||
bool moon64;
|
||||
bool s_toggles;
|
||||
bool s_machinima;
|
||||
bool s_cceditor;
|
||||
bool s_appearance;
|
||||
bool s_options;
|
||||
bool texture_debug;
|
||||
bool n64Mode;
|
||||
|
|
Loading…
Reference in New Issue