-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from CGray1234/ui-rewrite
UI rewrite
- Loading branch information
Showing
20 changed files
with
348 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
# File from PinkCore: https://github.com/BSMGPink/PinkCore/blob/master/assets_include.cmake | ||
|
||
# credit goes to https://github.com/Lauriethefish for this | ||
# Directory where our arbitrary asset files are stored | ||
set(ASSETS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/assets) | ||
# Directory to save the object files generated by llvm-objcopy | ||
set(ASSET_BINARIES_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/binaryAssets) | ||
# Directory to save the prepended files to | ||
set(PREPENDED_ASSETS_DIR ${CMAKE_CURRENT_BINARY_DIR}/prependedAssets) | ||
set(ASSET_HEADER_PATH "${CMAKE_CURRENT_SOURCE_DIR}/include/assets.hpp") | ||
|
||
# Define a macro which we will use for defining the symbols to access our asset files below | ||
set(ASSET_HEADER_DATA | ||
"#pragma once | ||
#include <string_view> | ||
#include \"beatsaber-hook/shared/utils/typedefs.h\" | ||
struct IncludedAsset { | ||
IncludedAsset(uint8_t* start, uint8_t* end) : array(reinterpret_cast<Array<uint8_t>*>(start)) { | ||
array->klass = nullptr; | ||
array->monitor = nullptr; | ||
array->bounds = nullptr; | ||
array->max_length = end - start - 33; | ||
*(end - 1)= '\\0'; | ||
} | ||
operator ArrayW<uint8_t>() const { | ||
init(); | ||
return array; | ||
} | ||
operator std::string_view() const { | ||
return { reinterpret_cast<char*>(array->values), array->Length() }; | ||
} | ||
operator std::span<uint8_t>() const { | ||
return { array->values, array->Length() }; | ||
} | ||
void init() const { | ||
if(!array->klass) | ||
array->klass = classof(Array<uint8_t>*); | ||
} | ||
private: | ||
Array<uint8_t>* array; | ||
}; | ||
#define DECLARE_FILE(name) \\ | ||
extern \"C\" uint8_t _binary_##name##_start[]; \\ | ||
extern \"C\" uint8_t _binary_##name##_end[]; \\ | ||
const IncludedAsset name { _binary_##name##_start, _binary_##name##_end}; | ||
namespace IncludedAssets { | ||
\n") | ||
|
||
if (EXISTS ${ASSETS_DIRECTORY}) | ||
file(MAKE_DIRECTORY ${ASSET_BINARIES_DIRECTORY}) | ||
file(MAKE_DIRECTORY ${PREPENDED_ASSETS_DIR}) | ||
file(GLOB ASSETS LIST_DIRECTORIES false ${ASSETS_DIRECTORY}/*) | ||
|
||
# Iterate through each file in the assets directory. TODO: This could be recursive | ||
foreach(FILE IN LISTS ASSETS) | ||
message("-- Including asset: ${FILE}") | ||
get_filename_component(ASSET ${FILE} NAME) # Find the asset's file name | ||
|
||
# make a copy of the file with 32 bytes added in the build dir | ||
add_custom_command( | ||
OUTPUT ${PREPENDED_ASSETS_DIR}/${ASSET} | ||
COMMAND ${CMAKE_COMMAND} -E echo_append " " > ${PREPENDED_ASSETS_DIR}/${ASSET} | ||
COMMAND ${CMAKE_COMMAND} -E cat ${ASSETS_DIRECTORY}/${ASSET} >> ${PREPENDED_ASSETS_DIR}/${ASSET} | ||
COMMAND ${CMAKE_COMMAND} -E echo_append " " >> ${PREPENDED_ASSETS_DIR}/${ASSET} | ||
DEPENDS ${ASSETS_DIRECTORY}/${ASSET} | ||
) | ||
|
||
set(OUTPUT_FILE "${ASSET_BINARIES_DIRECTORY}/${ASSET}.o") # Save our asset in the asset binaries directory | ||
|
||
# Use llvm-objcopy to create an object file that stores our binary asset | ||
# The resulting file contains 3 symbols: _binary_<file_name>_start, _binary_<file_name>_size and _binary_<file_name>_end | ||
# We only use the first two | ||
add_custom_command( | ||
OUTPUT ${OUTPUT_FILE} | ||
COMMAND ${CMAKE_OBJCOPY} ${ASSET} ${OUTPUT_FILE} --input-target binary --output-target elf64-aarch64 --set-section-flags binary=strings | ||
DEPENDS ${PREPENDED_ASSETS_DIR}/${ASSET} | ||
WORKING_DIRECTORY ${PREPENDED_ASSETS_DIR} | ||
) | ||
list(APPEND BINARY_ASSET_FILES ${OUTPUT_FILE}) | ||
|
||
# Find the correct objcopy symbol name, this is always the file name with any non-alphanumeric characters replaced with _ | ||
string(REGEX REPLACE "[^a-zA-Z0-9]" "_" FIXED_ASSET ${ASSET}) | ||
# Add to our assets header | ||
set(ASSET_HEADER_DATA "${ASSET_HEADER_DATA}\tDECLARE_FILE(${FIXED_ASSET})\n") | ||
endforeach() | ||
set(ASSET_HEADER_DATA "${ASSET_HEADER_DATA}\n}\n") | ||
|
||
# check if at least 1 asset file, otherwise ignore | ||
list(LENGTH BINARY_ASSET_FILES COUNT) | ||
if (${COUNT} GREATER 0) | ||
# Generate the assets header file | ||
file(GENERATE OUTPUT ${ASSET_HEADER_PATH} CONTENT "${ASSET_HEADER_DATA}") | ||
|
||
# Add our assets files to the final SO | ||
add_library(asset_files OBJECT ${BINARY_ASSET_FILES}) | ||
set_target_properties(asset_files PROPERTIES LINKER_LANGUAGE CXX) | ||
target_link_libraries(${COMPILE_ID} PRIVATE asset_files ${BINARY_ASSET_FILES}) | ||
endif() | ||
else() | ||
message("-- Removing '${ASSET_HEADER_PATH}' as no assets have been found in '${ASSETS_DIRECTORY}'") | ||
file(REMOVE ${ASSET_HEADER_PATH}) | ||
endif() |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// From PinkCore: https://github.com/BSMGPink/PinkCore/blob/master/include/Utils/UIUtils.hpp | ||
|
||
#pragma once | ||
|
||
#include "UnityEngine/UI/Button.hpp" | ||
#include "UnityEngine/Sprite.hpp" | ||
#include <string> | ||
|
||
namespace UIUtils | ||
{ | ||
void SwapButtonSprites(UnityEngine::UI::Button* button, UnityEngine::Sprite* normal, UnityEngine::Sprite* highlighted); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#pragma once | ||
#include <string_view> | ||
#include "beatsaber-hook/shared/utils/typedefs.h" | ||
struct IncludedAsset { | ||
IncludedAsset(uint8_t* start, uint8_t* end) : array(reinterpret_cast<Array<uint8_t>*>(start)) { | ||
array->klass = nullptr; | ||
array->monitor = nullptr; | ||
array->bounds = nullptr; | ||
array->max_length = end - start - 33; | ||
*(end - 1)= '\0'; | ||
} | ||
|
||
operator ArrayW<uint8_t>() const { | ||
init(); | ||
return array; | ||
} | ||
operator std::string_view() const { | ||
return { reinterpret_cast<char*>(array->values), array->Length() }; | ||
} | ||
|
||
operator std::span<uint8_t>() const { | ||
return { array->values, array->Length() }; | ||
} | ||
void init() const { | ||
if(!array->klass) | ||
array->klass = classof(Array<uint8_t>*); | ||
} | ||
private: | ||
Array<uint8_t>* array; | ||
}; | ||
#define DECLARE_FILE(name) \ | ||
extern "C" uint8_t _binary_##name##_start[]; \ | ||
extern "C" uint8_t _binary_##name##_end[]; \ | ||
const IncludedAsset name { _binary_##name##_start, _binary_##name##_end}; | ||
namespace IncludedAssets { | ||
|
||
DECLARE_FILE(MiscGradient_png) | ||
DECLARE_FILE(MiscGradientSelected_png) | ||
DECLARE_FILE(PosGradient_png) | ||
DECLARE_FILE(PosGradientSelected_png) | ||
DECLARE_FILE(RotGradient_png) | ||
DECLARE_FILE(RotGradientSelected_png) | ||
|
||
} |
Oops, something went wrong.