Skip to content

Commit

Permalink
gifs test
Browse files Browse the repository at this point in the history
  • Loading branch information
user95401 committed Dec 16, 2024
1 parent 3166b3c commit 1e23eeb
Show file tree
Hide file tree
Showing 33 changed files with 4,215 additions and 7 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ add_subdirectory($ENV{GEODE_SDK} ${CMAKE_CURRENT_BINARY_DIR}/geode)

#mod

file(GLOB_RECURSE SRC src/*.c*)
file(GLOB_RECURSE SRC src/*.c* src/**/*.c*)
add_library(${PROJECT_NAME} SHARED ${SRC} )
message("SRC: ${SRC}")

include_directories(src)
include_directories(src/libs)

setup_geode_mod(${PROJECT_NAME})

Expand Down
4 changes: 3 additions & 1 deletion mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"id": "user95401.gemetry_trash",
"name": "Gemetry Trash",
"version": "v3.1.0",
"version": "v3.1.1-beta.1",
"developer": "user95401",
"description": "",
"early-load": true,
Expand Down Expand Up @@ -39,13 +39,15 @@
"resources/**/*.ogg",
"resources/**/*.wav",
"resources/**/*.plist",
"resources/**/*.gif",
"resources/**/*.rand",
"resources/**/*.sfx*",
"resources/**/**/*.mpg",
"resources/**/**/*.mp3",
"resources/**/**/*.ogg",
"resources/**/**/*.wav",
"resources/**/**/*.plist",
"resources/**/**/*.gif",
"resources/**/**/*.rand",
"resources/**/**/*.sfx*"
]
Expand Down
Binary file added resources/files/NX_vcjZmQ9w.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/files/NX_vcjZmQ9w.mp3
Binary file not shown.
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.
30 changes: 25 additions & 5 deletions src/icons_ext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,13 @@ class $modify(PlayerObjectIconsExt, PlayerObject) {
if (this == nullptr) return index;

GameManagerIconsExt::return_original_count_for_type->setVisible(1);
//log::warn("{} = {}", index, GameManager::get()->countForType(type));
if (index == GameManager::get()->countForType(type)) {//fucking checks
index == GameManager::get()->activeIconForType(type);
}
auto original_count = GameManager::get()->countForType(type);
GameManagerIconsExt::return_original_count_for_type->setVisible(0);

if ((index != original_count) or (index != (original_count + 1))) {//fucking checks
index = GameManager::get()->activeIconForType(type);
}

auto names = frameNamesInVec(index, type);

if (not forVehicle) {
Expand Down Expand Up @@ -144,9 +145,14 @@ class $modify(PlayerObjectIconsExt, PlayerObject) {

return index;
}
$override bool init(int p0, int p1, GJBaseGameLayer* p2, cocos2d::CCLayer* p3, bool p4) {
if (!PlayerObject::init(p0, p1, p2, p3, p4)) return false;
PlayerObject::updatePlayerFrame(m_maybeSavedPlayerFrame);
return true;
}
$override void updatePlayerFrame(int p0) {
PlayerObject::updatePlayerFrame(p0);
this->m_iconRequestID = customFramesUpateFor(p0, IconType::Cube);
this->m_maybeSavedPlayerFrame = customFramesUpateFor(p0, IconType::Cube);
}
$override void updatePlayerShipFrame(int p0) {
PlayerObject::updatePlayerShipFrame(p0);
Expand Down Expand Up @@ -206,4 +212,18 @@ class $modify(SimplePlayerIconsExt, SimplePlayer) {
auto names = frameNamesInVec(index, type);
setFrames(names[0], names[1], names[2], names[3], names[4]);
}
};

#include <Geode/modify/GJGarageLayer.hpp>
class $modify(GJGarageLayerIconsExt, GJGarageLayer) {
$override void setupPage(int p0, IconType p1) {
if (GameManager::sharedState()->countForType(p1) <= 36) p0 = 0;
GJGarageLayer::setupPage(p0, p1);
if (m_playerObject) m_playerObject->updatePlayerFrame(
GameManager::get()->activeIconForType(
GameManager::get()->m_playerIconType
),
GameManager::get()->m_playerIconType
);
}
};
118 changes: 118 additions & 0 deletions src/libs/Gif/Bitmap.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#include "Bitmap.h"

Bitmap::Bitmap()
{
m_width = 0;
m_hight = 0;
m_data = NULL;
};

Bitmap::~Bitmap()
{
resetBitmap();
};

void Bitmap::allocateBitmap()
{
assert(m_data == NULL && m_width * m_hight > 0);
m_data = (Rgba*)malloc(m_width * m_hight * sizeof(Rgba));
};

void Bitmap::resetBitmap()
{
if(m_data)
{
free(m_data);
m_data = NULL;
}
};

bool Bitmap::hasData()
{
return m_data != NULL;
}

bool Bitmap::isValid()
{
return m_width > 0 && m_hight >0 && hasData();
}

uint32_t Bitmap::getPixelLenth()
{
return m_width*m_hight;
};

const uint32_t* Bitmap::getRGBA()
{
if(m_data == NULL)
{
return NULL;
}
return (uint32_t *) m_data;
}

void Bitmap::eraseColor(Rgba color)
{
Rgba paintColor = color;

// make rgb premultiplied
if (255 != color.alpha) {
paintColor.red = AlphaMul(color.red, color.alpha);
paintColor.green = AlphaMul(color.green, color.alpha);
paintColor.blue = AlphaMul(color.blue, color.alpha);
}

for (uint32_t i = 0; i < m_width * m_hight; i++)
*(m_data + i) = paintColor;
}

Bitmap* Bitmap::getDebugBitmap()
{
Bitmap* bitmap = new Bitmap;
bitmap->m_width = 64;
bitmap->m_hight = 64;

bitmap->allocateBitmap();
for(uint32_t hight =0; hight < bitmap->m_hight; hight++ )
{
Rgba color ;
color.alpha = 255;
if(hight < 20)
{
color.red = 255;
color.green = 0;
color.blue = 0;
}else if(hight >= 20 && hight < 40)
{
color.red = 0;
color.green = 255;
color.blue = 0;
}else
{
color.red = 0;
color.green = 0;
color.blue = 255;
}

for(uint32_t width = 0; width < bitmap->m_width; width++)
{
Rgba& colorPixel = bitmap->m_data[hight*bitmap->m_width + width];
colorPixel = color;
}

}

return bitmap;
}

Rgba* Bitmap::getAddr(int left, int top)
{
return m_data + top * m_width + left;
}

void Bitmap::swap(Bitmap* toSwap)
{
TSwap(this->m_data, toSwap->m_data);
TSwap(this->m_width, toSwap->m_width);
TSwap(this->m_hight, toSwap->m_hight);
}
96 changes: 96 additions & 0 deletions src/libs/Gif/Bitmap.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#ifndef BITMAP_H
#define BITMAP_H

#include <stdint.h>
#include <assert.h>
#include <cstdlib>
#include "GifMacros.h"

#define ColorType uint8_t
#define UNINITIALIZED_UINT ((uint32_t)-1)

class Rgba
{
public:
Rgba()
{
blue = 0;
green = 0;
red = 0;
alpha = 0;
}
Rgba(ColorType ialpha, ColorType ired, ColorType igreen, ColorType iblue)
{
alpha = ialpha;
red = ired;
green = igreen;
blue = iblue;
}

Rgba(Rgba& color)
{
alpha = color.alpha;
blue = color.blue;
green = color.green;
red = color.red;
}

void setColor(ColorType ialpha, ColorType ired, ColorType igreen, ColorType iblue)
{
alpha = ialpha;
red = ired;
green = igreen;
blue = iblue;
}
ColorType red;
ColorType green;
ColorType blue;
ColorType alpha;
};

class Bitmap{

public:

uint32_t m_width;
uint32_t m_hight;

Bitmap();
virtual ~Bitmap();
void allocateBitmap();
void resetBitmap();
bool hasData();
bool isValid();
uint32_t getPixelLenth();
const uint32_t* getRGBA();
Rgba* getAddr(int left, int top);
void swap(Bitmap*);
void eraseColor(Rgba color);
static Bitmap* getDebugBitmap();
private:
Rgba* m_data;
};

struct FrameData
{
uint32_t m_duration;
uint32_t m_index;
FrameData(uint32_t duration, uint32_t index)
{
m_duration = duration;
m_index = index;
}
};

class GifFrame
{
public:
GifFrame()
:m_frameData(UNINITIALIZED_UINT, UNINITIALIZED_UINT)
{
}
Bitmap* m_bm;
FrameData m_frameData;
};

#endif
Loading

0 comments on commit 1e23eeb

Please sign in to comment.