Added ave and craig

This commit is contained in:
2023-08-01 23:06:47 -07:00
parent 24ab09b451
commit 9fd31edc4a
8 changed files with 75 additions and 8 deletions

View File

@ -0,0 +1,26 @@
name: build-liminal-glfw-linux64
on:
push:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Toolchain
run: ./ci/install-linux-toolchain.sh
- name: Install Libraries
run: ./ci/install-libraries.sh
- name: Build Tools
run: ./ci/build-tools.sh
- name: Build Game
run: |
mkdir build
cd build
cmake .. -DDAWN_BUILD_TARGET=target-liminial-linux64-glfw
make

2
ci/install-linux-toolchain.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/bash
sudo apt install build-essential

View File

@ -18,7 +18,7 @@ void AssetLoader::open() {
assertNull(this->handle, "AssetLoader::open: File is already open");
std::string pathFull = DAWN_ASSET_BUILD_PREFIX + this->fileName;
this->handle = fopen(pathFull.c_str(), "rb");
assertNotNull(this->handle, "AssetLoader::open: Failed to open file");
assertNotNull(this->handle, "AssetLoader::open: Failed to open file " + pathFull);
}
int32_t AssetLoader::close() {

View File

@ -15,7 +15,7 @@ namespace Dawn {
protected:
void onStart() override {
assertNotNull(this->modifies);
assertNotNull(this->modifies, "VNSetEvent::onStart() modifies is null!");
*modifies = value;
this->next();
}

View File

@ -34,6 +34,28 @@ struct Color Color::fromString(std::string str) {
return COLOR_BLUE;
}
// Hex code?
// Split by comma
auto splitByComma = stringSplit(str, ",");
if(splitByComma.size() == 3) {
// RGB
return {
(float_t)std::stof(splitByComma[0]),
(float_t)std::stof(splitByComma[1]),
(float_t)std::stof(splitByComma[2]),
1.0f
};
} else if(splitByComma.size() == 4) {
// RGBA
return {
(float_t)std::stof(splitByComma[0]),
(float_t)std::stof(splitByComma[1]),
(float_t)std::stof(splitByComma[2]),
(float_t)std::stof(splitByComma[3])
};
}
// TODO: Parse other kinds of colors
assertUnreachable("Failed to find a color match for " + str);
return {};

View File

@ -124,7 +124,7 @@ namespace Dawn {
};
static inline std::string colorParser(std::string v, std::string *error) {
return rawParser(v, error);
return "Color::fromString(" + stringParser(v, error) + ")";
}
static inline std::function<std::string(std::string, std::string*)> parserFromTypeName(std::string type) {

View File

@ -83,6 +83,7 @@ function(tool_texture target)
--cropStartY="${CROP_START_Y}"
--cropEndX="${CROP_END_X}"
--cropEndY="${CROP_END_Y}"
--preview="${DAWN_BUILD_DIR}/preview/${target}"
COMMENT "Generating texture ${target} from ${FILE}"
DEPENDS ${DEPS}
)

View File

@ -25,7 +25,8 @@ std::map<std::string, std::string> TextureTool::getOptionalFlags() {
{ "cropStartX", "" },
{ "cropStartY", "" },
{ "cropEndX", "" },
{ "cropEndY", "" }
{ "cropEndY", "" },
{ "preview", "" }
};
}
@ -73,14 +74,14 @@ int32_t TextureTool::start() {
if(!flags["cropEndY"].empty()) cropEndY = std::stoi(flags["cropEndY"]);
if(cropStartX > 0 || cropStartY > 0 || cropEndX > 0 || cropEndY > 0) {
int32_t cropWidth = originalWidth - cropStartX - cropEndX;
int32_t cropHeight = originalHeight - cropStartY - cropEndY;
int32_t cropWidth = (cropEndX == 0 ? originalWidth : cropEndX) - cropStartX;
int32_t cropHeight = (cropEndY == 0 ? originalHeight : cropEndY) - cropStartY;
float_t s0, t0, s1, t1;
s0 = (float_t)cropStartX / (float_t)originalWidth;
t0 = (float_t)cropStartY / (float_t)originalHeight;
s1 = 1.0f - ((float_t)cropEndX / (float_t)originalWidth);
t1 = 1.0f - ((float_t)cropEndY / (float_t)originalHeight);
s1 = ((float_t)(cropEndX == 0 ? originalWidth : cropEndX) / (float_t)originalWidth);
t1 = ((float_t)(cropEndY == 0 ? originalHeight : cropEndY) / (float_t)originalHeight);
stbir_resize_region(
bufferCurrent, currentWidth, currentHeight, 0,
@ -165,6 +166,21 @@ int32_t TextureTool::start() {
return 1;
}
// Write preview
File preview(flags["preview"] + ".png");
if(!preview.mkdirp()) {
std::cout << "Failed to make preview dir " << preview.filename << std::endl;
return 1;
}
stbi_write_png(
preview.filename.c_str(),
currentWidth,
currentHeight,
STBI_rgb_alpha,
bufferCurrent,
0
);
// Write texture
if(!out.writeRaw((char*)bufferCurrent, sizeof(uint8_t) * len)) {
std::cout << "Failed to write texture data for " << out.filename << std::endl;