commit 688def7e01e74a47579ea8bf7e9f8fca393949e4 Author: jettis Date: Thu Dec 5 20:49:37 2024 +0200 initial commit diff --git a/Animal.cpp b/Animal.cpp new file mode 100644 index 0000000..636bc66 --- /dev/null +++ b/Animal.cpp @@ -0,0 +1,358 @@ +#include +#include +#include + +#include +#include + +#include + +#include "Animal.h" + +#include "embed.h" + +using namespace std; + +SkinsEmbed skins_embed; + +Animal::Animal(string skin) { + move_time = 0; + animate_time = 0; + random_time = 0; + cur = 0; + viime_event = 0; + state_changed = false; + + // set rand seed + SDL_srand(0); + + readSkin(skin); + setSpecialState(drop); +} + +Animal::~Animal() { +} + +SDL_Surface *Animal::readImg(string skin, string state_name, int num) { + SDL_Surface *pet; + embed_data *img_buf = skins_embed.getSkin(skin, state_name); + if (img_buf) { // load from embedded if exists + SDL_IOStream *io = SDL_IOFromConstMem(img_buf[num].data, img_buf[num].len); + if (io == NULL) { + SDL_Log("could not open io for pet: %s\n", SDL_GetError()); + } + pet = IMG_Load_IO(io, true); + if (pet == NULL) { + SDL_Log("could not create pet surface: %s\n", SDL_GetError()); + } + } else { + stringstream file_name; + file_name << "skin/" << skin << "/" << state_name << "/" << (num + 1) << ".png"; + pet = IMG_Load(file_name.str().c_str()); + if (pet == NULL) { + SDL_Log("could not create pet surface: %s\n", SDL_GetError()); + } + } + + // SDL_CreateTexture can't handle palette formats, so check if needs converting + if (pet && pet->format <= SDL_PIXELFORMAT_INDEX8) { + SDL_Surface *tmp = pet; + pet = SDL_ConvertSurface(pet, SDL_GetPixelFormatForMasks(32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000)); + SDL_DestroySurface(tmp); + } + + if (pet && !SDL_ISPIXELFORMAT_ALPHA(pet->format)) { + /* Set the colorkey to the top-left pixel */ + Uint8 r, g, b, a; + + SDL_ReadSurfacePixel(pet, 0, 0, &r, &g, &b, &a); + SDL_SetSurfaceColorKey(pet, 1, SDL_MapSurfaceRGBA(pet, r, g, b, a)); + } + + return pet; +} + +void Animal::readSkin(string skin) { + + string buf; + string key; + State feat; + char prev_chr; + + states.clear(); + special_states.clear(); + random_states.clear(); + + special_states.resize(SPECIAL_STATE_LAST); + + string params = skins_embed.getParams(skin); + if (params.length()) { // load from embedded if exists + for (string::iterator it = params.begin(); it != params.end(); ++it) { + readSkinStep(skin, *it, buf, key, feat, prev_chr); + } + } else { + stringstream file_name; + file_name << "skin/" << skin << ".tsk"; + FILE *tied = fopen(file_name.str().c_str(), "rb"); + if (!tied) { + cout << "Skin file fail: " << file_name.str() << endl; + } + while(!feof(tied)) { + char chr = fgetc(tied); + readSkinStep(skin, chr, buf, key, feat, prev_chr); + } + fclose(tied); + } + + if (!feat.name.empty()) { + readSkinFill(skin, feat); + + feat.name.clear(); + feat.sound.clear(); + feat.sound_data.loop = 0; + } +} + +void Animal::readSkinStep(string skin, char chr, string &buf, string &key, State &feat, char &prev_chr) { + if (chr == '\n') { + if (prev_chr == '\n' && !feat.name.empty()) { + readSkinFill(skin, feat); + + feat.name.clear(); + feat.sound.clear(); + feat.sound_data.loop = 0; + } + + if (key == "name") + feat.name = buf; + if (key == "img_name") + feat.img_name = buf; + if (key == "count") + feat.count = atoi(buf.c_str()); + if (key == "interval") + feat.interval = atoi(buf.c_str()); + if (key == "x") + feat.x = atoi(buf.c_str()); + if (key == "y") + feat.y = atoi(buf.c_str()); + if (key == "sound") + feat.sound = buf.c_str(); + if (key == "loop") + feat.sound_data.loop = atoi(buf.c_str()); + buf.clear(); + } else if (chr == '=') { + key = buf; + buf.clear(); + } else { + buf.push_back(chr); + } + + prev_chr = chr; +} + +void Animal::readSkinFill(string skin, State feat) { + states.push_back(feat); + + // Load images to memory + cur_state = &states.back(); + for (int x = 0; x < cur_state->count; x++) { + cur_state->imgs.push_back(NULL); + cur_state->imgs[x] = readImg(skin, cur_state->img_name, x); + } + + if (feat.sound.empty()) { + cur_state->sound_data.len = 0; + } else { + pair buf = skins_embed.getSound(skin, cur_state->img_name); + if (buf.first) { // load from embedded if exists + SDL_IOStream *io = SDL_IOFromConstMem(buf.first, buf.second); + if (io == NULL) { + SDL_Log("could not open io for sound: %s\n", SDL_GetError()); + } + if (!SDL_LoadWAV_IO(io, true, &cur_state->sound_data.spec, &cur_state->sound_data.buf, &cur_state->sound_data.len)) { + SDL_Log("failed to load audio: %s", SDL_GetError()); + } + } else { + stringstream file_name; + file_name << "skin/" << skin << "/" << cur_state->img_name << "/" << cur_state->sound; + if (!SDL_LoadWAV(file_name.str().c_str(), &cur_state->sound_data.spec, &cur_state->sound_data.buf, &cur_state->sound_data.len)) { + SDL_Log("failed to load audio %s: %s", file_name.str().c_str(), SDL_GetError()); + } + } + } + + // Special state cases + cur_state->interruptable = true; + if (cur_state->name == "stay") { + cur_state->special = stay; + random_states.push_back(cur_state); + } else if (cur_state->name == "drop") { + cur_state->special = drop; + cur_state->interruptable = false; + } else if (cur_state->name == "jump") { + cur_state->special = jump; + random_states.push_back(cur_state); + cur_state->interruptable = false; + } else if (cur_state->name == "jump_end") { + cur_state->special = jump_end; + cur_state->interruptable = false; + } else if (cur_state->name == "flop") { + cur_state->special = flop; + } else if (cur_state->name == "hang") { + cur_state->special = hang; + cur_state->interruptable = false; + } else if (cur_state->name == "fast_right") { + cur_state->special = fast_right; + random_states.push_back(cur_state); + } else if (cur_state->name == "fast_left") { + cur_state->special = fast_left; + random_states.push_back(cur_state); + } else { + cur_state->special = NOTHING; + random_states.push_back(cur_state); + } + if (cur_state->special) { + special_states[cur_state->special] = cur_state; + } +} + +void Animal::move() { + disp_pos.x += cur_state->x; + disp_pos.y += cur_state->y; + + // Don't go out of display on right side + if (disp_pos.x + getImage()->w > disp_pos.w) { + setSpecialState(stay); + if (disp_pos.y < getImage()->h - 150) { + setSpecialState(drop); + } + disp_pos.x = disp_pos.w - getImage()->w - 2; + } + + // Donät fo out of display on left side + if (disp_pos.x < 0) { + setSpecialState(stay); + if (disp_pos.y < disp_pos.h - 150) { + setSpecialState(drop); + } + disp_pos.x = 2; + } + + // Check if we have jumped high enough + if (disp_pos.y < disp_pos.h - 300 && cur_state->name == "jump") { + setSpecialState(jump_end); + } + + // Check if if hit the ground + if (disp_pos.y >= disp_pos.h - 150) { + if (cur_state->name == "jump_end") { + setSpecialState(stay); + } else if (cur_state->name == "drop") { + setSpecialState(flop); + } + } +} + +void Animal::animate(bool reset){ + if (reset) { + animation_i = 0; + } else if (animation_i >= cur_state->count - 1) { + animation_i = 0; + } else { + animation_i++; + } +} + +void Animal::shuffle() { + // Check if we are in a cur_state where we can't do anything + if (cur_state->interruptable) { + int lot = SDL_rand(random_states.size()); + setState(random_states[lot]); + } +} + +void Animal::setState(State *s) { + cur_state = s; + cur_state->sound_data.is_played = false; + animate(true); + state_changed = true; +} + +void Animal::setSpecialState(SpecialState s) { + //SDL_Log("special_state %d", s); + cur_state = special_states[s]; + //SDL_Log("cur_state %x", cur_state); + cur_state->sound_data.is_played = false; + animate(true); + state_changed = true; +} + +void Animal::resetTimes(Uint64 t) { + move_time = random_time = t; +} + +Uint64 Animal::step(Uint64 cur, bool press) { + if (!press && cur >= move_time) { + move(); + move_time += 25; + } + + if (cur >= animate_time) { + animate(false); + animate_time += cur_state->interval; + } + + if (!press && cur >= random_time) { + shuffle(); + random_time += 1000 * 5; + } + + Uint64 lowest_time = move_time; + if (lowest_time > animate_time) lowest_time = animate_time; + if (lowest_time > random_time) lowest_time = random_time; + + if (lowest_time < cur) { + lowest_time = cur; + } + + return lowest_time - cur; +} + +SDL_Surface *Animal::getImage() { + return cur_state->imgs[animation_i]; +} + +SoundData *Animal::getSound() { + return &cur_state->sound_data; +} + +bool Animal::hasStateChanged() { + if (state_changed) { + state_changed = false; + return true; + } + return false; +} + +void Animal::shouldRunAway(char dir) { + // Check if we are in a cur_state where we can't do anything + if (cur_state->interruptable) { + if (dir == 1) { + if (cur_state->special != fast_right) { + setSpecialState(fast_right); + } + } else { + if (cur_state->special != fast_left) { + setSpecialState(fast_left); + } + } + } +} + +SDL_Surface *Animal::getPreviewSurface() { + if (special_states[stay]->imgs.size()) { + return special_states[stay]->imgs[0]; + } else { + return NULL; + } +} diff --git a/Animal.h b/Animal.h new file mode 100644 index 0000000..1671759 --- /dev/null +++ b/Animal.h @@ -0,0 +1,75 @@ +#ifndef ANIMAL_H +#define ANIMAL_H + +#include +#include + +#include +#include +#include + +#include "SoundData.h" + +using namespace std; + +// These States have something special logic in code (other than just randomly picked) +enum SpecialState { NOTHING, stay, drop, jump, jump_end, flop, hang, fast_right, fast_left, SPECIAL_STATE_LAST }; + + +class State { + public: + string name; + string img_name; + int count; + int interval; + int x; + int y; + string sound; + SpecialState special; + bool interruptable; + + vector imgs; + SoundData sound_data; +}; + +class Animal { + public: + + Animal(string skin); + ~Animal(); + SDL_Surface *readImg(string skin, string state_name, int num); + void readSkin(string file); + void readSkinStep(string skin, char chr, string &buf, string &key, State &state, char &prev_chr); + void readSkinFill(string skin, State state); + void createShape(int num, int w, int h); + void move(); + void animate(bool reset); + void shuffle(); + void setState(State *s); + void setSpecialState(SpecialState s); + void resetTimes(Uint64 t); + Uint64 step(Uint64 cur, bool press); + SDL_Surface *getImage(); + SoundData *getSound(); + bool hasStateChanged(); + void shouldRunAway(char dir); + SDL_Surface *getPreviewSurface(); + + SDL_Rect disp_pos; // has display width and height and window posiion on it + + vector states; + vector special_states; + State *cur_state; + vector random_states; + + int animation_i; + + Uint64 move_time; + Uint64 animate_time; + Uint64 random_time; + Uint64 cur; + bool viime_event; + bool state_changed; +}; + +#endif diff --git a/INSTALL.mingw32-linux b/INSTALL.mingw32-linux new file mode 100644 index 0000000..c92fff4 --- /dev/null +++ b/INSTALL.mingw32-linux @@ -0,0 +1,122 @@ +On Arch Linux: + +yay -S mingw-w64-environment mingw-w64-pkg-config mingw-w64-make mingw-w64-cmake mingw-w64-sdl3 + +PKGBUILD like this for mingw-w64-sdl3_ttf-git: +------------------------------------ +pkgname=mingw-w64-sdl3_ttf-git +pkgver=r1011.582c695 +pkgrel=1 +pkgdesc="Support for TrueType (.ttf) font files with Simple Directmedia Layer (Version 3)" +arch=('any') +url="https://github.com/libsdl-org/SDL_ttf.git" +license=('Zlib') +depends=('mingw-w64-crt') +makedepends=('mingw-w64-cmake' 'ninja') +source=("git+https://github.com/libsdl-org/SDL_ttf") +sha256sums=('SKIP') +provides=('mingw-w64-sdl3_ttf') +conflicts=('mingw-w64-sdl3_ttf') +options=('!debug' '!buildflags' '!strip' 'staticlibs') + +_architectures="i686-w64-mingw32 x86_64-w64-mingw32" + +pkgver() { + cd "${srcdir}/SDL_ttf" + printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short=7 HEAD)" +} + +build() { + cd "${srcdir}/SDL_ttf" + cd external + ./download.sh + cd .. + #cmake -B build -D SDLTTF_SAMPLES=OFF -D CMAKE_INSTALL_PREFIX=/usr + #cmake --build build + for _arch in ${_architectures}; do + BUILD_OPTS=("-DCMAKE_INSTALL_PREFIX=/usr/${_arch}" + '-DSDLTTF_SAMPLES=OFF' + '-DSDLTTF_VENDORED=ON') + + ${_arch}-cmake -B build/${_arch}-static -G Ninja \ + -DBUILD_SHARED_LIBS=OFF \ + ${BUILD_OPTS[@]} + + ${_arch}-cmake -B build/${_arch} -G Ninja \ + -DBUILD_SHARED_LIBS=ON \ + ${BUILD_OPTS[@]} + + cmake --build build/${_arch}-static + cmake --build build/${_arch} + done +} + +package() { + cd "${srcdir}/SDL_ttf" + #DESTDIR="${pkgdir}" cmake --install build + for _arch in ${_architectures}; do + DESTDIR="${pkgdir}" cmake --install build/${_arch}-static + DESTDIR="${pkgdir}" cmake --install build/${_arch} + ${_arch}-strip --strip-unneeded "${pkgdir}"/usr/${_arch}/bin/*.dll + ${_arch}-strip -g "${pkgdir}"/usr/${_arch}/lib/*.a + done +} +------------------------------------ + + + +PKGBUILD like tihs for mingw-w64-sdl3_image-git: +------------------------------------ +pkgname=mingw-w64-sdl3_image-git +pkgver=r1563.0d418a2 +pkgrel=1 +pkgdesc="Image decoding for many popular formats for Simple Directmedia Layer (Version 3)" +arch=('any') +url="https://github.com/libsdl-org/SDL_image.git" +license=('Zlib') +depends=('mingw-w64-cmake' 'ninja' ) +source=("git+https://github.com/libsdl-org/SDL_image") +sha256sums=('SKIP') +provides=('mingw-w64-sdl3_image') +conflicts=('mingw-w64-sdl3_image') +options=('!debug' '!buildflags' '!strip' 'staticlibs') + +_architectures="i686-w64-mingw32 x86_64-w64-mingw32" + +pkgver() { + cd "${srcdir}/SDL_image" + printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short=7 HEAD)" +} + +build() { + cd "${srcdir}/SDL_image" + #cmake -B build -D CMAKE_INSTALL_PREFIX=/usr + #cmake --build build + + for _arch in ${_architectures}; do + BUILD_OPTS=("-DCMAKE_INSTALL_PREFIX=/usr/${_arch}") + + ${_arch}-cmake -B build/${_arch}-static -G Ninja \ + -DBUILD_SHARED_LIBS=OFF \ + ${BUILD_OPTS[@]} + + ${_arch}-cmake -B build/${_arch} -G Ninja \ + -DBUILD_SHARED_LIBS=ON \ + ${BUILD_OPTS[@]} + + cmake --build build/${_arch}-static + cmake --build build/${_arch} + done +} + +package() { + cd "${srcdir}/SDL_image" + #DESTDIR="${pkgdir}" cmake --install build + for _arch in ${_architectures}; do + DESTDIR="${pkgdir}" cmake --install build/${_arch}-static + DESTDIR="${pkgdir}" cmake --install build/${_arch} + ${_arch}-strip --strip-unneeded "${pkgdir}"/usr/${_arch}/bin/*.dll + ${_arch}-strip -g "${pkgdir}"/usr/${_arch}/lib/*.a + done +} +------------------------------------ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d73a39f --- /dev/null +++ b/Makefile @@ -0,0 +1,25 @@ +CXX=g++ + +# needs "override" because x86_64-w64-mingw32-make sets these as cmdline parameters +override CXXFLAGS += -c -Wall -g +override LDFLAGS += $(shell pkg-config --libs sdl3 sdl3-ttf sdl3-image) + +NEW_DIALOG_OBJECTS = Dialog Item Button Checkbox DropDownList Scrollbar Listbox Frame DlgDropDownList DlgMainMenu +OBJECTS=main Animal Sound $(addprefix NewDialogs/,$(NEW_DIALOG_OBJECTS)) +EXECUTABLE=Rousku + +all: $(EXECUTABLE) + +$(EXECUTABLE): $(OBJECTS:%=%.o) + $(CXX) $^ $(LDFLAGS) -o $@ + +# pull in dependency info for *existing* .o files +-include $(OBJECTS:%=%.d) + +%.o: %.cpp + $(CXX) $(CXXFLAGS) $< -o $@ + $(CXX) -MM $(CXXFLAGS) $*.cpp > $*.d + +.PHONY: clean +clean: + rm `find . -name "*.o"` `find . -name "*.d"` $(EXECUTABLE) diff --git a/Makefile.mingw b/Makefile.mingw new file mode 100644 index 0000000..38a9999 --- /dev/null +++ b/Makefile.mingw @@ -0,0 +1,26 @@ +CXX=g++ + +# needs "override" because x86_64-w64-mingw32-make sets these as cmdline parameters +override CXXFLAGS += -c -Wall -static +override LDFLAGS += $(shell pkg-config --libs sdl3 sdl3-ttf sdl3-image) -lwinmm -lwindowsapp -lsetupapi -limm32 -lversion -lole32 -lmincore -luuid -static + +NEW_DIALOG_OBJECTS = Dialog Item Button Checkbox DropDownList Scrollbar Listbox Frame DlgDropDownList DlgMainMenu +OBJECTS=main Animal Sound $(addprefix NewDialogs/,$(NEW_DIALOG_OBJECTS)) +EXECUTABLE=Rousku + +all: $(EXECUTABLE) + +$(EXECUTABLE): $(OBJECTS:%=%.o) + $(RC) icon.rc icon.o + $(CXX) $^ icon.o $(LDFLAGS) -o $@ + +# pull in dependency info for *existing* .o files +-include $(OBJECTS:%=%.d) + +%.o: %.cpp + $(CXX) $(CXXFLAGS) $< -o $@ + $(CXX) -MM $(CXXFLAGS) $*.cpp > $*.d + +.PHONY: clean +clean: + rm `find . -name "*.o"` `find . -name "*.d"` $(EXECUTABLE) diff --git a/NewDialogs/Button.cpp b/NewDialogs/Button.cpp new file mode 100644 index 0000000..882a74d --- /dev/null +++ b/NewDialogs/Button.cpp @@ -0,0 +1,205 @@ +#include +#include + +using namespace std; + +#include + +#include "../SDLHelpers.h" + +#include "Button.h" + +Button::Button(string text, SDL_Color color, SDL_Rect pos) : Item(pos) { + this->color = color; + this->text = text; + pressed = false; + selected = false; + toggle_selected = false; + button_func = NULL; + button_press_func = NULL; + button_release_func = NULL; + drawButton(); + selectSurface(); +} + +Button::~Button() { + SDL_DestroySurface(button_up); + SDL_DestroySurface(button_down); +} + +/*void Button::init() { + buttonPressed = false; + drawButton(); + setSurface(buttonUp); +}*/ + +/*void Button::destroy() { + SDL_FreeSurface(buttonUp); + SDL_FreeSurface(buttonDown); +}*/ + +void Button::drawButton() { + //Uint32 color = 0xFFE6DCDC; + //SDL_Color color = 0xFFB4C8B4; + //Uint32 color = 0xFFB4B4C8; + SDL_Color color_reflection = color; + SDL_Color color_shadow = color; + color_reflection.r = (int) color_reflection.r + 50 < 255 ? color_reflection.r + 50 : 255; + color_reflection.g = (int) color_reflection.g + 50 < 255 ? color_reflection.g + 50 : 255; + color_reflection.b = (int) color_reflection.b + 50 < 255 ? color_reflection.b + 50 : 255; + color_shadow.r = (int) color_shadow.r - 50 > 0 ? color_shadow.r - 50 : 0; + color_shadow.g = (int) color_shadow.g - 50 > 0 ? color_shadow.g - 50 : 0; + color_shadow.b = (int) color_shadow.b - 50 > 0 ? color_shadow.b - 50 : 0; + + int w = getPos()->w; + int h = getPos()->h; + button_up = SDL_CreateSurface(w, h, SDL_GetPixelFormatForMasks(32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000)); + button_down = SDL_CreateSurface(w, h, SDL_GetPixelFormatForMasks(32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000)); + Uint32 *p_up = (Uint32 *) button_up->pixels; + Uint32 *p_down = (Uint32 *) button_down->pixels; + SDL_Color color_up; + SDL_Color color_down; + for (int y = 0; y < h; y++) { + for (int x = 0; x < w; x++) { + if (y == 0 || y == h-1 || x == 0 || x == w-1) { + color_up.r = 0; + color_up.g = 0; + color_up.b = 0; + color_down = color_up; + } else if (y == 1 || x == 1) { + color_up = color_reflection; + color_down = color_shadow; + } else if (y == h-2 || x == w-2) { + color_up = color_shadow; + color_down = color_reflection; + } else { + color_up = color; + if ((y + x) % 2 == 0) { + color_down = color; + } else { + color_down.r = 255; + color_down.g = 255; + color_down.b = 255; + } + } + *p_up = SDL_MapRGB(SDL_GetPixelFormatDetails(button_up->format), NULL, color_up.r, color_up.g, color_up.b); + *p_down = SDL_MapRGB(SDL_GetPixelFormatDetails(button_down->format), NULL, color_down.r, color_down.g, color_down.b); + p_up++; + p_down++; + } + } + + SDL_Color text_color = {0, 0, 0}; + vector fonts; + fonts.push_back("DejaVuSans.ttf"); + fonts.push_back("ariblk.ttf"); + fonts.push_back("FreeSans.ttf"); + fonts.push_back("arial.ttf"); + TTF_Font *font = openFont(fonts, 10); + SDL_Surface *text_surface; + if (!font) + cout << "TTF_OpenFont is broken!" << endl; + if(!(text_surface = TTF_RenderText_Blended(font, text.c_str(), text.length(), text_color))) + cout << SDL_GetError() << endl; + SDL_Rect pos; + pos.x = button_up->w / 2 - text_surface->w / 2; + pos.y = button_up->h / 2 - text_surface->h / 2; + SDL_BlitSurface(text_surface, NULL, button_up, &pos); + SDL_BlitSurface(text_surface, NULL, button_down, &pos); + SDL_DestroySurface(text_surface); + TTF_CloseFont(font); +} + +bool Button::onMousePress(int x, int y) { + bool isInX = x > getPos()->x && x < getPos()->x + getPos()->w; + bool isInY = y > getPos()->y && y < getPos()->y + getPos()->h; + if (isInX && isInY) { + pressed = true; + if (button_press_func) { + (*button_press_func)(p, this); + } + selectSurface(); + return true; + } + return false; +} + +void Button::onMouseRelease(int x, int y) { + if (pressed) { + bool is_in_x = x > getPos()->x && x < getPos()->x + getPos()->w; + bool is_in_y = y > getPos()->y && y < getPos()->y + getPos()->h; + if (is_in_x && is_in_y) { + if (toggle_selected) { + selected = !selected; + } + if (button_func) { + (*button_func)(p, this); + } + } + if (button_release_func) { + (*button_release_func)(p, this); + } + pressed = false; + selectSurface(); + } +} + +void Button::onFingerDown(int x, int y, int finger_id) { + if (onMousePress(x, y)) { + this->finger_id = finger_id; + } +} + +void Button::onFingerUp(int x, int y, int finger_id) { + if (pressed && this->finger_id == finger_id) { + onMouseRelease(x, y); + } +} + +void Button::setButtonFunc(void (*button_func)(void *p, Item *b), void *p) { + this->button_func = button_func; + this->p = p; +} + +void Button::setButtonPressFunc(void (*button_press_func)(void *p, Item *b), void *p) { + this->button_press_func = button_press_func; + this->p = p; +} + +void Button::setButtonReleaseFunc(void (*button_release_func)(void *p, Item *b), void *p) { + this->button_release_func = button_release_func; + this->p = p; +} + +void Button::setText(string text) { + this->text = text; +} + +string Button::getText() { + return text; +} + +void Button::setColor(SDL_Color color) { + this->color = color; +} + +void Button::setSelected(bool selected) { + this->selected = selected; + selectSurface(); +} + +bool Button::isSelected() { + return selected; +} + +void Button::selectSurface() { + if (pressed) { + setSurface(button_down); + } else { + if (selected) { + setSurface(button_down); + } else { + setSurface(button_up); + } + } +} diff --git a/NewDialogs/Button.h b/NewDialogs/Button.h new file mode 100644 index 0000000..3496030 --- /dev/null +++ b/NewDialogs/Button.h @@ -0,0 +1,44 @@ +#ifndef BUTTON_H +#define BUTTON_H + +#include + +#include "Item.h" + +class Button : public Item { +protected: + string text; + SDL_Color color; + SDL_Surface *button_up; + SDL_Surface *button_down; + bool toggle_selected; +private: + bool pressed; + bool selected; + int finger_id; + void (*button_func)(void *p, Item *b); + void (*button_press_func)(void *p, Item *b); + void (*button_release_func)(void *p, Item *b); + void *p; +public: + //void init(); + //void destroy(); + Button(string text, SDL_Color color, SDL_Rect pos); + virtual ~Button(); + virtual void drawButton(); + bool onMousePress(int x, int y); + void onMouseRelease(int x, int y); + void onFingerDown(int x, int y, int finger_id); + void onFingerUp(int x, int y, int finger_id); + void setButtonFunc(void (*button_func)(void *p, Item *b), void *p); + void setButtonPressFunc(void (*button_press_func)(void *p, Item *b), void *p); + void setButtonReleaseFunc(void (*button_release_func)(void *p, Item *b), void *p); + void setText(string text); + string getText(); + void setColor(SDL_Color color); + void setSelected(bool selected); + bool isSelected(); + void selectSurface(); +}; + +#endif diff --git a/NewDialogs/Checkbox.cpp b/NewDialogs/Checkbox.cpp new file mode 100644 index 0000000..8c58dd9 --- /dev/null +++ b/NewDialogs/Checkbox.cpp @@ -0,0 +1,117 @@ +#include + +using namespace std; + +#include +#include + +#include "../SDLHelpers.h" + +#include "Checkbox.h" + +bool isBetween(float a, float b, float c) { + return a >= b && a < c; +} + +Checkbox::Checkbox(string text, SDL_Color color, SDL_Rect pos) : Button(text, color, pos) { + //SDL_Color color; + //Button::Button(text, color, pos); + toggle_selected = true; + // Parent Button doesn't seem to call this but it's own drawButton. So doing it again for here. FIXME how to fix? + SDL_DestroySurface(button_up); + SDL_DestroySurface(button_down); + drawButton(); + selectSurface(); +} + +Checkbox::~Checkbox() { +} + +void Checkbox::drawButton() { + SDL_Color color_reflection = color; + SDL_Color color_shadow = color; + color_reflection.r = (int) color_reflection.r + 50 < 255 ? color_reflection.r + 50 : 255; + color_reflection.g = (int) color_reflection.g + 50 < 255 ? color_reflection.g + 50 : 255; + color_reflection.b = (int) color_reflection.b + 50 < 255 ? color_reflection.b + 50 : 255; + color_shadow.r = (int) color_shadow.r - 50 > 0 ? color_shadow.r - 50 : 0; + color_shadow.g = (int) color_shadow.g - 50 > 0 ? color_shadow.g - 50 : 0; + color_shadow.b = (int) color_shadow.b - 50 > 0 ? color_shadow.b - 50 : 0; + + int w = getPos()->w; + int h = getPos()->h; + button_up = SDL_CreateSurface(w, h, SDL_GetPixelFormatForMasks(32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000)); + button_down = SDL_CreateSurface(w, h, SDL_GetPixelFormatForMasks(32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000)); + Uint32 *p_up = (Uint32 *) button_up->pixels; + Uint32 *p_down = (Uint32 *) button_down->pixels; + SDL_Color color_up; + SDL_Color color_down; + for (int y = 0; y < h; y++) { + for (int x = 0; x < w; x++) { // checkbox needs to be square so using height + float u = h / 12.0; // one unit (was 1 pixel in example image) + color_up.a = 0xff; + color_down.a = 0xff; + if (x > h) { + color_up.a = 0; + color_down.a = 0; + } else if (isBetween(y, h - u, h) || isBetween(x, h - u, h)) { // reflection + color_up.r = 0xd4; + color_up.g = 0xd0; + color_up.b = 0xc8; + color_down = color_up; + } else if (isBetween(y, 0, u) || isBetween(x, 0, u)) { // lighter shadow + color_up.r = 0x80; + color_up.g = 0x80; + color_up.b = 0x80; + color_down = color_up; + } else if (isBetween(y, u, u * 2) || isBetween(x, u, u * 2)) { // darker shadow + color_up.r = 0x40; + color_up.g = 0x40; + color_up.b = 0x40; + color_down = color_up; + } else { + color_up.r = 255; + color_up.g = 255; + color_up.b = 255; + color_down = color_up; + bool x_cond = isBetween(x, u * 3, 10 * u); + bool y_cond = isBetween(y, x + u * 1.5, x + u * 4.5); + float x_change_limit = 5.5 * u; + if (x >= x_change_limit) { + unsigned remaining_x = (x - x_change_limit); + y_cond = isBetween(y, u * 7 - remaining_x, u * 10 - remaining_x); + } + if (x_cond && y_cond) { + color_down.r = 0; + color_down.g = 0; + color_down.b = 0; + } + } + *p_up = SDL_MapRGBA(SDL_GetPixelFormatDetails(button_up->format), NULL, color_up.r, color_up.g, color_up.b, color_up.a); + *p_down = SDL_MapRGBA(SDL_GetPixelFormatDetails(button_down->format), NULL, color_down.r, color_down.g, color_down.b, color_down.a); + p_up++; + p_down++; + } + } + + SDL_Color text_color = {0, 0, 0}; + vector fonts; + fonts.push_back("DejaVuSans.ttf"); + fonts.push_back("ariblk.ttf"); + fonts.push_back("FreeSans.ttf"); + fonts.push_back("arial.ttf"); + TTF_Font *font = openFont(fonts, 10); + SDL_Surface *text_surface; + if (!font) { + SDL_Log("TTF_OpenFont is broken!"); + } + if(!(text_surface = TTF_RenderText_Blended(font, text.c_str(), text.length(), text_color))) { + SDL_Log("RenderText failed %s", SDL_GetError()); + } + SDL_Rect pos; + pos.x = button_up->h + 8; + pos.y = button_up->h / 2 - text_surface->h / 2; + SDL_BlitSurface(text_surface, NULL, button_up, &pos); + SDL_BlitSurface(text_surface, NULL, button_down, &pos); + SDL_DestroySurface(text_surface); + TTF_CloseFont(font); +} diff --git a/NewDialogs/Checkbox.h b/NewDialogs/Checkbox.h new file mode 100644 index 0000000..b8ccbdd --- /dev/null +++ b/NewDialogs/Checkbox.h @@ -0,0 +1,14 @@ +#ifndef CHECKBOX_H +#define CHECKBOX_H + +#include "Button.h" + +class Checkbox : public Button { +private: +public: + Checkbox(string text, SDL_Color color, SDL_Rect pos); + virtual ~Checkbox(); + virtual void drawButton() override; +}; + +#endif diff --git a/NewDialogs/Dialog.cpp b/NewDialogs/Dialog.cpp new file mode 100644 index 0000000..0ac4e68 --- /dev/null +++ b/NewDialogs/Dialog.cpp @@ -0,0 +1,128 @@ +#include + +using namespace std; + +#include + +#include "Item.h" +#include "Dialog.h" + +bool Dialog::loadBackground(string name) { + background = IMG_Load(name.c_str()); + if (!background) + return false; + surface = SDL_CreateSurface(background->w, background->h, SDL_GetPixelFormatForMasks(32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000)); + SDL_Rect d; + d.x = 0; + d.y = 0; + d.w = background->w; + d.h = background->h; + SDL_SetSurfaceClipRect(surface, &d); + pos.w = background->w; + pos.h = background->h; + default_pos = true; + return true; +} + +void Dialog::addItem(Item *item) { + items.push_back(item); +} + +void Dialog::deleteItems() { + for (unsigned int z = 0; z < items.size(); z++) { + delete items[z]; + } +} + +bool Dialog::needsRedraw() { + return true; // always drawing, only performance optimizaion on some dialogs which override this method +} + +void Dialog::draw() { + if (background) { + SDL_BlitSurface(background, NULL, surface, NULL); + } + for (unsigned int x = 0; x < items.size(); x++) { + SDL_BlitSurface(items[x]->getSurface(), NULL, surface, items[x]->getPos()); + items[x]->drawDone(); + } +} + +SDL_Surface *Dialog::getSurface() { + if (needsRedraw()) { + draw(); + } + return surface; +} + +void Dialog::deleteSurfaceAndBackground() { + delete background; + delete surface; +} + +bool Dialog::onMousePress(int x, int y) { + if (x < 0 || y < 0 || x > surface->w || y > surface->h) { + exit = true; + return false; + } + for (unsigned int z = 0; z < items.size(); z++) { + items[z]->onMousePress(x, y); + } + return false; +} + +bool Dialog::onMouseRelease(int x, int y) { + for (unsigned int z = 0; z < items.size(); z++) { + items[z]->onMouseRelease(x, y); + } + return false; +} + +bool Dialog::onMouseMove(int x, int y) { + for (unsigned int z = 0; z < items.size(); z++) { + items[z]->onMouseMove(x, y); + } + return false; +} + +bool Dialog::onFingerDown(int x, int y, int finger_id) { + if (x < 0 || y < 0 || x > surface->w || y > surface->h) { + exit = true; + return false; + } + for (unsigned int z = 0; z < items.size(); z++) { + items[z]->onFingerDown(x, y, finger_id); + } + return false; +} + +bool Dialog::onFingerUp(int x, int y, int finger_id) { + for (unsigned int z = 0; z < items.size(); z++) { + items[z]->onFingerUp(x, y, finger_id); + } + return false; +} + +void Dialog::setPos(SDL_Rect pos) { + this->pos = pos; +} + +SDL_Rect *Dialog::getPos() { + return &pos; +} + +void Dialog::setExit(bool exit) { + this->exit = exit; +} + +bool Dialog::isExit() { + return exit; +} + +bool Dialog::isDefaultPos() { + return default_pos; +} + +void Dialog::setDefaultPos(bool default_pos) { + this->default_pos = default_pos; +} diff --git a/NewDialogs/Dialog.h b/NewDialogs/Dialog.h new file mode 100644 index 0000000..2abbf72 --- /dev/null +++ b/NewDialogs/Dialog.h @@ -0,0 +1,42 @@ +#ifndef DIALOG_H +#define DIALOG_H + +#include + +using namespace std; + +#include + +#include "Item.h" + +class Dialog { +protected: + SDL_Surface *surface; + SDL_Surface *background; + SDL_Rect pos; + vector items; +private: + bool default_pos; + bool exit; +public: + bool loadBackground(string name); + void addItem(Item *item); + void deleteItems(); + virtual bool needsRedraw(); + virtual void draw(); + SDL_Surface *getSurface(); + void deleteSurfaceAndBackground(); + virtual bool onMousePress(int x, int y); + virtual bool onMouseRelease(int x, int y); + virtual bool onMouseMove(int x, int y); + virtual bool onFingerDown(int x, int y, int finger_id); + virtual bool onFingerUp(int x, int y, int finger_id); + void setPos(SDL_Rect pos); + SDL_Rect *getPos(); + void setExit(bool exit); + bool isExit(); + bool isDefaultPos(); + void setDefaultPos(bool default_pos); +}; + +#endif diff --git a/NewDialogs/DlgDropDownList.cpp b/NewDialogs/DlgDropDownList.cpp new file mode 100644 index 0000000..8af8106 --- /dev/null +++ b/NewDialogs/DlgDropDownList.cpp @@ -0,0 +1,69 @@ +#include + +using namespace std; + +#include +#include +#include + +#include "../SDLHelpers.h" + +#include "Item.h" +#include "Scrollbar.h" +#include "Listbox.h" +#include "Frame.h" + +#include "DlgDropDownList.h" + +DlgDropDownList::DlgDropDownList(DropDownList *ddl, SDL_Rect pos, bool add_scrollbar) : Dialog() { + this->ddl = ddl; + this->pos = pos; + setDefaultPos(false); + + background = SDL_CreateSurface(pos.w, pos.h, SDL_GetPixelFormatForMasks(32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000)); + memset((int *) background->pixels, 0xFFFFFFFF, pos.w * pos.h * 4); + surface = SDL_CreateSurface(background->w, background->h, SDL_GetPixelFormatForMasks(32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000)); + + int listbox_width = pos.w; + if (add_scrollbar) + listbox_width -= 18; + Item *listbox = new Listbox(ddl->getList(), ddl->getListboxItemSize(), getRect(0, 0, listbox_width, ddl->getListboxHeight())); + ((Listbox *) listbox)->setValueChangedFunc(&listboxValueChangedCallback, (void *)this); + + Item *item = new Frame(getRect(0, 0, listbox_width, pos.h)); + ((Frame *)item)->addItem(listbox); + addItem(item); + + if (add_scrollbar) { + item = new Scrollbar(0, ddl->getListboxHeight() - pos.h, 0, getRect(pos.w - 18, 0, 18, pos.h)); + ((Scrollbar *) item)->setValueChangedFunc(&scrollbarValueChangedCallback, (void *)this); + addItem(item); + } + + setExit(false); +} + +DlgDropDownList::~DlgDropDownList() { + deleteSurfaceAndBackground(); + deleteItems(); +} + +void DlgDropDownList::listboxValueChangedCallback(void *p) { + ((DlgDropDownList *)p)->listboxValueChanged(); +} + +void DlgDropDownList::listboxValueChanged() { + int selected = ((Listbox *)((Frame *) items[0])->getItem(0))->getSelected(); + ddl->setSelected(selected); + setExit(true); +} + +void DlgDropDownList::scrollbarValueChangedCallback(void *p) { + ((DlgDropDownList *)p)->scrollbarValueChanged(); +} + +void DlgDropDownList::scrollbarValueChanged() { + int value = ((Scrollbar *) items[1])->getValue(); + SDL_Rect *pos = ((Frame *) items[0])->getItem(0)->getPos(); + pos->y = 0 - value; +} diff --git a/NewDialogs/DlgDropDownList.h b/NewDialogs/DlgDropDownList.h new file mode 100644 index 0000000..5034640 --- /dev/null +++ b/NewDialogs/DlgDropDownList.h @@ -0,0 +1,19 @@ +#ifndef DLG_DROP_DOWN_LIST +#define DLG_DROP_DOWN_LIST + +#include "Dialog.h" +#include "DropDownList.h" + +class DlgDropDownList : public Dialog { +private: + DropDownList *ddl; +public: + DlgDropDownList(DropDownList *ddl, SDL_Rect pos, bool add_scrollbar); + ~DlgDropDownList(); + static void listboxValueChangedCallback(void *p); + void listboxValueChanged(); + static void scrollbarValueChangedCallback(void *p); + void scrollbarValueChanged(); +}; + +#endif diff --git a/NewDialogs/DlgMainMenu.cpp b/NewDialogs/DlgMainMenu.cpp new file mode 100644 index 0000000..17c013a --- /dev/null +++ b/NewDialogs/DlgMainMenu.cpp @@ -0,0 +1,287 @@ +#include +#include +#include +#include +#include +#include + +using namespace std; + +#include +#include +#include +#include + +#include "../SDLHelpers.h" + +#include "Item.h" +#include "Button.h" +#include "Dialog.h" +#include "Frame.h" + +#include "DlgMainMenu.h" + +#include "../menu_png.h" + +SDL_EnumerationResult enumStorage(void *userdata, const char *dirname, const char *fname) { + SDL_Log("dirname %s fname %s", dirname, fname); + SDL_Storage *storage = (SDL_Storage *) ((pair *)userdata)->first; + vector *list = (vector *) ((pair *)userdata)->second; + string path("skin/"); + path += fname; + SDL_PathInfo pi; + SDL_GetStoragePathInfo(storage, path.c_str(), &pi); + if (pi.type == SDL_PATHTYPE_DIRECTORY) { + SDL_Log("is dir"); + // add name to list if list does not yet have it + if (find(list->begin(), list->end(), fname) == list->end()) { + list->push_back(fname); + } + } + return SDL_ENUM_CONTINUE; +} + +DlgMainMenu::DlgMainMenu() : Dialog() { + if (!loadBackground()) { + cerr << "Background open failed menu_png! " << SDL_GetError() << endl; + } + + vector list; + // adding embedded skins + list.push_back("Tavallinen"); + list.push_back("Alppisusi"); + list.push_back("Chibi"); + + SDL_Storage *storage = SDL_OpenTitleStorage(NULL, 0); + if (!storage) { + SDL_Log("Error opening title storage %s", SDL_GetError()); + } + pair userdata(storage, &list); + if (!SDL_EnumerateStorageDirectory(storage, "skin", &enumStorage, &userdata)) { + SDL_Log("Error enumerating dir %s", SDL_GetError()); + } + + always_on_top_checkbox = new Checkbox("Pysy päällimmäisenä", getColor(0, 0, 0), getRect(16, 24, 200, 12)); + always_on_top_checkbox->setSelected(1); + always_on_top_checkbox->setButtonFunc(&settingsChangedCallback, (void *)this); + always_on_top_checkbox->setName("always_on_top"); + addItem(always_on_top_checkbox); + + enable_sound_checkbox = new Checkbox("Äänet päälle / pois päältä", getColor(0, 0, 0), getRect(16, 40, 200, 12)); + enable_sound_checkbox->setSelected(1); + enable_sound_checkbox->setButtonFunc(&settingsChangedCallback, (void *)this); + enable_sound_checkbox->setName("enable_sound"); + addItem(enable_sound_checkbox); + + open_menu_on_start_checkbox = new Checkbox("Avaa valikko Rouskun käynnistyessä", getColor(0, 0, 0), getRect(16, 56, 200, 12)); + open_menu_on_start_checkbox->setSelected(1); + open_menu_on_start_checkbox->setButtonFunc(&settingsChangedCallback, (void *)this); + open_menu_on_start_checkbox->setName("open_menu_on_start"); + addItem(open_menu_on_start_checkbox); + + run_away_from_mouse_checkbox = new Checkbox("Juokse hiirtä karkuun", getColor(0, 0, 0), getRect(16, 72, 200, 12)); + run_away_from_mouse_checkbox->setSelected(0); + run_away_from_mouse_checkbox->setButtonFunc(&settingsChangedCallback, (void *)this); + run_away_from_mouse_checkbox->setName("run_away_from_mouse"); + addItem(run_away_from_mouse_checkbox); + + skin_list = new DropDownList(list, &dialogs, getRect(16, 104, 200, 25)); + skin_list->setSelected(0); + skin_list->setValueChangedFunc(&settingsChangedCallback, (void *)this); + skin_list->setName("skin_list"); + addItem(skin_list); + + Item *item = new Button("Sulje valikko", getColor(0xB4, 0xC8, 0xB4), getRect(135, 320, 95, 27)); + ((Button *) item)->setButtonFunc(&contCallback, (void *)this); + addItem(item); + + item = new Button("Sulje Rousku", getColor(0xC8, 0xB4, 0xB4), getRect(7, 320, 95, 27)); + ((Button *) item)->setButtonFunc(&quitCallback, (void *)this); + addItem(item); + + readSettings(); + setExit(false); + if (!open_menu_on_start_checkbox->isSelected()) { + setExit(true); + } + + app_exit = false; +} + +DlgMainMenu::~DlgMainMenu() { + deleteSurfaceAndBackground(); + deleteItems(); +} + +void DlgMainMenu::draw() { + Dialog::draw(); + + // Just drawing preview surface on dialog. Create own Item for preview if needed at some point. + if (preview_sfe) { + SDL_Rect r = { 57, 128, preview_sfe->w, preview_sfe->h }; + SDL_BlitSurface(preview_sfe, NULL, surface, &r); + } + + // We just draw dialogs on this dialog's surface + for (unsigned int x = 0; x < dialogs.size(); x++) { + SDL_BlitSurface(dialogs[x]->getSurface(), NULL, surface, dialogs[x]->getPos()); + //items[x]->drawDone(); + } +} + +bool DlgMainMenu::onMousePress(int x, int y) { + // we are handling other dialogs as integrated to this dialog so passing our events to them + for (unsigned int z = 0; z < dialogs.size(); z++) { + dialogs[z]->onMousePress(x - dialogs[z]->getPos()->x, y - dialogs[z]->getPos()->y); + if (dialogs[z]->isExit()) { + delete dialogs[z]; + dialogs[z] = NULL; + dialogs.erase(dialogs.begin()+z); + z--; + } + } + return Dialog::onMousePress(x, y); +} + +bool DlgMainMenu::onMouseRelease(int x, int y) { + // we are handling other dialogs as integrated to this dialog so passing our events to them + for (unsigned int z = 0; z < dialogs.size(); z++) { + dialogs[z]->onMouseRelease(x - dialogs[z]->getPos()->x, y - dialogs[z]->getPos()->y); + } + return Dialog::onMouseRelease(x, y); +} + +void DlgMainMenu::readSettings() { + SDL_Storage *strg = SDL_OpenUserStorage("TeamSaunakauha", "Rousku", 0); + Uint64 file_size; + if (!SDL_GetStorageFileSize(strg, "mem.tsk", &file_size)) { + SDL_Log("could not get mem.tsk size %s", SDL_GetError()); + return; + } + char buf[file_size]; + if (!SDL_ReadStorageFile(strg, "mem.tsk", buf, file_size)) { + SDL_Log("mem.tsk read failed %s", SDL_GetError()); + return; + } + + SDL_CloseStorage(strg); + + string sbuf(buf, file_size); + istringstream ssbuf(sbuf); + string line; + Uint8 lc = 0; + while (getline(ssbuf, line)) { + switch(lc++) { + case 0: always_on_top_checkbox->setSelected(line == "1"); break; + case 1: enable_sound_checkbox->setSelected(line == "1"); break; + case 2: open_menu_on_start_checkbox->setSelected(line == "1"); break; + case 3: run_away_from_mouse_checkbox->setSelected(line == "1"); break; + case 4: skin_list->select(line); break; + } + } +} + +void DlgMainMenu::writeSettings() { + stringstream ssbuf; + ssbuf << (always_on_top_checkbox->isSelected() ? 1 : 0) << endl; + ssbuf << (enable_sound_checkbox->isSelected() ? 1 : 0) << endl; + ssbuf << (open_menu_on_start_checkbox->isSelected() ? 1 : 0) << endl; + ssbuf << (run_away_from_mouse_checkbox->isSelected() ? 1 : 0) << endl; + ssbuf << skin_list->getString() << endl; + + SDL_Storage *strg = SDL_OpenUserStorage("TeamSaunakauha", "Rousku", 0); + if (!SDL_WriteStorageFile(strg, "mem.tsk", ssbuf.str().c_str(), ssbuf.str().length())) { + SDL_Log("mem.tsk write failed %s", SDL_GetError()); + return; + } + SDL_CloseStorage(strg); +} + +void DlgMainMenu::contCallback(void *p, Item *i) { + ((DlgMainMenu *)p)->cont(); +} + +void DlgMainMenu::cont() { + setExit(true); +} + +void DlgMainMenu::quitCallback(void *p, Item *i) { + ((DlgMainMenu *)p)->quit(); +} + +void DlgMainMenu::quit() { + setAppExit(true); +} + +void DlgMainMenu::settingsChangedCallback(void *p, Item *i) { + ((DlgMainMenu *)p)->settingsChanged(i); +} + +void DlgMainMenu::settingsChanged(Item *i) { + writeSettings(); + if (i->getName().length()) { + settings_changed_list.push_back(i->getName()); + } +} + +void DlgMainMenu::setAppExit(bool app_exit) { + this->app_exit = app_exit; +} + +bool DlgMainMenu::isAppExit() { + return app_exit; +} + +bool DlgMainMenu::isAlwaysOnTop() { + return always_on_top_checkbox->isSelected(); +} + +bool DlgMainMenu::isEnableSound() { + return enable_sound_checkbox->isSelected(); +} + +bool DlgMainMenu::isRunAwayFromMouse() { + return run_away_from_mouse_checkbox->isSelected(); +} + +string DlgMainMenu::getSkin() { + return skin_list->getString(); +} + +string DlgMainMenu::getChangedSetting() { + if (settings_changed_list.size()) { + string name = settings_changed_list.back(); + settings_changed_list.pop_back(); + return name; + } else { + return ""; + } +} + +void DlgMainMenu::setPreviewSurface(SDL_Surface *preview_sfe) { + this->preview_sfe = preview_sfe; +} + +bool DlgMainMenu::loadBackground() { + SDL_IOStream *io = SDL_IOFromConstMem(menu_png, menu_png_len); + if (io == NULL) { + SDL_Log("could not open io for menu_png: %s\n", SDL_GetError()); + return false; + } + background = IMG_Load_IO(io, true); + if (background == NULL) { + SDL_Log("could not create pet surface: %s\n", SDL_GetError()); + return false; + } + surface = SDL_CreateSurface(background->w, background->h, SDL_GetPixelFormatForMasks(32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000)); + SDL_Rect d; + d.x = 0; + d.y = 0; + d.w = background->w; + d.h = background->h; + SDL_SetSurfaceClipRect(surface, &d); + pos.w = background->w; + pos.h = background->h; + return true; +} + diff --git a/NewDialogs/DlgMainMenu.h b/NewDialogs/DlgMainMenu.h new file mode 100644 index 0000000..75236a3 --- /dev/null +++ b/NewDialogs/DlgMainMenu.h @@ -0,0 +1,55 @@ +#ifndef DLG_MAIN_MENU +#define DLG_MAIN_MENU + +#include "Dialog.h" +#include "Button.h" +#include "DropDownList.h" +#include "Checkbox.h" + +#include + +#include + +using namespace std; + +class DlgMainMenu : public Dialog { +private: + vector dialogs; + + Checkbox *always_on_top_checkbox; + Checkbox *enable_sound_checkbox; + Checkbox *open_menu_on_start_checkbox; + Checkbox *run_away_from_mouse_checkbox; + DropDownList *skin_list; + + bool app_exit; + bool show_menu; + vector settings_changed_list; + + SDL_Surface *preview_sfe; +public: + DlgMainMenu(); + ~DlgMainMenu(); + void draw(); + bool onMousePress(int x, int y); + bool onMouseRelease(int x, int y); + void readSettings(); + void writeSettings(); + static void contCallback(void *p, Item *i); + void cont(); + static void quitCallback(void *p, Item *i); + void quit(); + static void settingsChangedCallback(void *p, Item *i); + void settingsChanged(Item *i); + void setAppExit(bool app_exit); + bool isAppExit(); + bool isAlwaysOnTop(); + bool isEnableSound(); + bool isRunAwayFromMouse(); + string getSkin(); + string getChangedSetting(); + void setPreviewSurface(SDL_Surface *preview_sfe); + bool loadBackground(); +}; + +#endif diff --git a/NewDialogs/DropDownList.cpp b/NewDialogs/DropDownList.cpp new file mode 100644 index 0000000..ec88a20 --- /dev/null +++ b/NewDialogs/DropDownList.cpp @@ -0,0 +1,158 @@ +#include +#include + +using namespace std; + +#include +#include + +#include "../SDLHelpers.h" + +#include "DropDownList.h" +#include "DlgDropDownList.h" + +DropDownList::DropDownList(vector list, vector *dialogs, SDL_Rect pos) : Item(pos) { + this->list = list; + this->dialogs = dialogs; + selected = 0; + pressed = false; + listbox_item_size = 20; + value_changed_func = NULL; + setSurface(SDL_CreateSurface(getPos()->w, getPos()->h, SDL_GetPixelFormatForMasks(32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000))); + drawDropDownList(); +} + +DropDownList::~DropDownList() { + SDL_DestroySurface(getSurface()); +} + +void DropDownList::drawDropDownList() { + listbox_height = list.size() * listbox_item_size; + + SDL_Surface *surface = getSurface(); + int w = getPos()->w; + int h = getPos()->h; + Uint32 *p = (Uint32 *) surface->pixels; + SDL_Color color; + for (int y = 0; y < h; y++) { + for (int x = 0; x < w; x++) { + if (y == 0 || y == h-1 || x == 0 || x == w-1 || x == w-18) { + color.r = 0; + color.g = 0; + color.b = 0; + } else { + color.r = 255; + color.g = 255; + color.b = 255; + } + *p = SDL_MapRGB(SDL_GetPixelFormatDetails(surface->format), NULL, color.r, color.g, color.b); + p++; + } + } + + //drawing arrow + p = (Uint32 *) surface->pixels; + int posx = w - 13; + int posy = h / 2 - 2; + for (int y = 0; y < 4; y++) { + for (int x = 0; x < 8 - y * 2; x++) { + p[(posy + y) * w + (posx + x + y)] = SDL_MapRGB(SDL_GetPixelFormatDetails(surface->format), NULL, color.r, color.g, color.b); + } + } + + SDL_Color text_color = {0, 0, 0}; + vector fonts; + fonts.push_back("ariblk.ttf"); + fonts.push_back("FreeSans.ttf"); + fonts.push_back("DejaVuSans.ttf"); + fonts.push_back("arial.ttf"); + TTF_Font *font = openFont(fonts, 14); + SDL_Surface *text_surface; + if (!font) + cout << "TTF_OpenFont is broken!" << endl; + if(!(text_surface = TTF_RenderText_Blended(font, list[selected].c_str(), list[selected].length(), text_color))) + cout << SDL_GetError() << endl; + SDL_Rect pos; + pos.x = 8; + pos.y = surface->h / 2 - text_surface->h / 2; + SDL_BlitSurface(text_surface, NULL, surface, &pos); + SDL_DestroySurface(text_surface); + TTF_CloseFont(font); +} + +bool DropDownList::onMousePress(int x, int y) { + bool is_in_x = x > getPos()->x && x < getPos()->x + getPos()->w; + bool is_in_y = y > getPos()->y && y < getPos()->y + getPos()->h; + if (is_in_x && is_in_y) { + //setSurface(buttonDown); + pressed = true; + return true; + } + return false; +} + +void DropDownList::onMouseRelease(int x, int y) { + bool is_in_x = x > getPos()->x && x < getPos()->x + getPos()->w; + bool is_in_y = y > getPos()->y && y < getPos()->y + getPos()->h; + if (is_in_x && is_in_y && pressed) { + int height; + bool add_scrollbar; + if (listbox_height < 200) { + height = listbox_height; + add_scrollbar = false; + } else { + height = 200; + add_scrollbar = true; + } + dialogs->push_back(new DlgDropDownList(this, getRect(getPos()->x, getPos()->y + getPos()->h, getPos()->w, height), add_scrollbar)); + } + //setSurface(buttonUp); + pressed = false; +} + +vector DropDownList::getList() { + return list; +} + +void DropDownList::setSelected(int selected) { + this->selected = selected; + if (value_changed_func) { + (*value_changed_func)(p, this); + } + drawDropDownList(); +} + +void DropDownList::setValueChangedFunc(void (*value_changed_func)(void *p, Item *i), void *p) { + this->value_changed_func = value_changed_func; + this->p = p; +} + +string DropDownList::getString() { + return list[selected]; +} + +void DropDownList::reset() { + list.clear(); +} + +void DropDownList::add(string s) { + list.push_back(s); +} + +bool DropDownList::select(string s) { + for (int x = 0; x < list.size(); x++) { + if (list[x].compare(s) == 0) { + setSelected(x); + return true; + } + } + return false; +} + +int DropDownList::getListboxItemSize() { + return listbox_item_size; +} + +int DropDownList::getListboxHeight() { + return listbox_height; +} diff --git a/NewDialogs/DropDownList.h b/NewDialogs/DropDownList.h new file mode 100644 index 0000000..703246f --- /dev/null +++ b/NewDialogs/DropDownList.h @@ -0,0 +1,40 @@ +#ifndef DROP_DOWN_LIST +#define DROP_DOWN_LIST + +#include + +#include + +using namespace std; + +#include "Item.h" +#include "Dialog.h" + +class DropDownList : public Item { +private: + vector list; + vector *dialogs; + int selected; + int listbox_item_size; + int listbox_height; + bool pressed; + void (*value_changed_func)(void *p, Item *i); + void *p; +public: + DropDownList(vector list, vector *dialogs, SDL_Rect pos); + ~DropDownList(); + void drawDropDownList(); + bool onMousePress(int x, int y); + void onMouseRelease(int x, int y); + vector getList(); + void setSelected(int selected); + void setValueChangedFunc(void (*value_changed_func)(void *p, Item *i), void *p); + string getString(); + void reset(); + void add(string s); + bool select(string s); + int getListboxItemSize(); + int getListboxHeight(); +}; + +#endif diff --git a/NewDialogs/Frame.cpp b/NewDialogs/Frame.cpp new file mode 100644 index 0000000..6b8b6d0 --- /dev/null +++ b/NewDialogs/Frame.cpp @@ -0,0 +1,65 @@ +#include "Frame.h" + +Frame::Frame(SDL_Rect pos) : Item(pos) { + setSurface(SDL_CreateSurface(getPos()->w, getPos()->h, SDL_GetPixelFormatForMasks(32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000))); + memset((int *) getSurface()->pixels, 0xFFFFFFFF, pos.w * pos.h * 4); +} + +Frame::~Frame() { + SDL_DestroySurface(getSurface()); + for (unsigned int z = 0; z < items.size(); z++) { + delete items[z]; + } +} + +SDL_Surface *Frame::getSurface() { + draw(); + return surface; +} + +void Frame::draw() { + for (unsigned int z = 0; z < items.size(); z++) { + SDL_Rect src = *items[z]->getPos(); + SDL_Rect dst = {0,0,0,0}; + if (src.x < 0) { + src.x *= -1; + } else { + dst.x = src.x; + src.x = 0; + } + if (src.y < 0) { + src.y *= -1; + } else { + dst.y = src.y; + src.y = 0; + } + SDL_BlitSurface(items[z]->getSurface(), &src, surface, &dst); + } +} + +void Frame::addItem(Item *item) { + items.push_back(item); +} + +Item *Frame::getItem(int i) { + return items[i]; +} + +bool Frame::onMousePress(int x, int y) { + for (unsigned int z = 0; z < items.size(); z++) { + items[z]->onMousePress(x - getPos()->x, y - getPos()->y); + } + return false; +} + +void Frame::onMouseRelease(int x, int y) { + for (unsigned int z = 0; z < items.size(); z++) { + items[z]->onMouseRelease(x - getPos()->x, y - getPos()->y); + } +} + +void Frame::onMouseMove(int x, int y) { + for (unsigned int z = 0; z < items.size(); z++) { + items[z]->onMouseMove(x - getPos()->x, y - getPos()->y); + } +} diff --git a/NewDialogs/Frame.h b/NewDialogs/Frame.h new file mode 100644 index 0000000..118cbd3 --- /dev/null +++ b/NewDialogs/Frame.h @@ -0,0 +1,27 @@ +#ifndef FRAME +#define FRAME + +#include + +using namespace std; + +#include + +#include "Item.h" + +class Frame : public Item { +protected: + vector items; +public: + Frame(SDL_Rect pos); + ~Frame(); + SDL_Surface *getSurface(); + void draw(); + void addItem(Item *item); + Item *getItem(int i); + bool onMousePress(int x, int y); + void onMouseRelease(int x, int y); + void onMouseMove(int x, int y); +}; + +#endif diff --git a/NewDialogs/Item.cpp b/NewDialogs/Item.cpp new file mode 100644 index 0000000..151c4ef --- /dev/null +++ b/NewDialogs/Item.cpp @@ -0,0 +1,58 @@ +#include "Item.h" + +Item::Item(SDL_Rect pos) { + this->pos = pos; + needs_redraw = true; +} + +Item::~Item() { +} + +SDL_Surface *Item::getSurface() { + return surface; +} + +void Item::setSurface(SDL_Surface *surface) { + needs_redraw = true; + this->surface = surface; +} + +void Item::setPos(SDL_Rect pos) { + this->pos = pos; +} + +SDL_Rect *Item::getPos() { + return &pos; +} + +bool Item::onMousePress(int x, int y) { + return false; +} + +void Item::onMouseRelease(int x, int y) { +} + +void Item::onMouseMove(int x, int y) { +} + +void Item::onFingerDown(int x, int y, int finger_id) { +} + +void Item::onFingerUp(int x, int y, int finger_id) { +} + +bool Item::needsRedraw() { + return needs_redraw; +} + +void Item::drawDone() { + needs_redraw = false; +} + +void Item::setName(string name) { + this->name = name; +} + +string Item::getName() { + return name; +} diff --git a/NewDialogs/Item.h b/NewDialogs/Item.h new file mode 100644 index 0000000..32c82ae --- /dev/null +++ b/NewDialogs/Item.h @@ -0,0 +1,35 @@ +#ifndef ITEM_H +#define ITEM_H + +#include + +#include + +using namespace std; + +class Item { +protected: + SDL_Surface *surface; + bool needs_redraw; +private: + SDL_Rect pos; + string name; +public: + Item(SDL_Rect pos); + virtual ~Item(); + virtual SDL_Surface *getSurface(); + void setSurface(SDL_Surface *surface); + void setPos(SDL_Rect pos); + SDL_Rect *getPos(); + virtual bool onMousePress(int x, int y); + virtual void onMouseRelease(int x, int y); + virtual void onMouseMove(int x, int y); + virtual void onFingerDown(int x, int y, int finger_id); + virtual void onFingerUp(int x, int y, int finger_id); + bool needsRedraw(); + void drawDone(); + void setName(string name); + string getName(); +}; + +#endif diff --git a/NewDialogs/Listbox.cpp b/NewDialogs/Listbox.cpp new file mode 100644 index 0000000..d7074a6 --- /dev/null +++ b/NewDialogs/Listbox.cpp @@ -0,0 +1,91 @@ +#include + +using namespace std; + +#include +#include + +#include "../SDLHelpers.h" + +#include "Listbox.h" + +Listbox::Listbox(vector list, int item_size, SDL_Rect pos) : Item(pos) { + this->list = list; + this->item_size = item_size; + selected = 1; + setSurface(SDL_CreateSurface(getPos()->w, getPos()->h, SDL_GetPixelFormatForMasks(32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000))); + drawListbox(); +} + +Listbox::~Listbox() { + SDL_DestroySurface(getSurface()); +} + +void Listbox::drawListbox() { + SDL_Surface *surface = getSurface(); + int w = getPos()->w; + int h = getPos()->h; + + Uint32 *p = (Uint32 *) surface->pixels; + SDL_Color color; + for (int y = 0; y < h; y++) { + for (int x = 0; x < w; x++) { + if (y == 0 || y == h-1 || x == 0 || x == w-1) { + color.r = 0; + color.g = 0; + color.b = 0; + } else { + color.r = 255; + color.g = 255; + color.b = 255; + } + *p = SDL_MapRGB(SDL_GetPixelFormatDetails(surface->format), NULL, color.r, color.g, color.b); + p++; + } + } + + vector fonts; + fonts.push_back("ariblk.ttf"); + fonts.push_back("FreeSans.ttf"); + fonts.push_back("DejaVuSans.ttf"); + TTF_Font *font = openFont(fonts, 14); + if (!font) { + cout << "TTF_OpenFont is broken!" << endl; + } else { + for (int x = 0; x < list.size(); x++) { + SDL_Color text_color = {0, 0, 0}; + SDL_Surface *text_surface; + if(!(text_surface = TTF_RenderText_Blended(font, list[x].c_str(), list[x].length(), text_color))) { + cout << SDL_GetError() << endl; + } + SDL_Rect pos; + pos.x = 8; + pos.y = x * item_size; + SDL_BlitSurface(text_surface, NULL, surface, &pos); + SDL_DestroySurface(text_surface); + } + TTF_CloseFont(font); + } +} + +bool Listbox::onMousePress(int x, int y) { + bool is_in_x = x > getPos()->x && x < getPos()->x + getPos()->w; + bool is_in_y = y > getPos()->y && y < getPos()->y + getPos()->h; + if (is_in_x && is_in_y) { + selected = (y - getPos()->y) / item_size; + if (value_changed_func) { + (*value_changed_func)(p); + } + return true; + } + return false; +} + +void Listbox::setValueChangedFunc(void (*value_changed_func)(void *p), void *p) { + this->value_changed_func = value_changed_func; + this->p = p; +} + +int Listbox::getSelected() { + return selected; +} diff --git a/NewDialogs/Listbox.h b/NewDialogs/Listbox.h new file mode 100644 index 0000000..3195326 --- /dev/null +++ b/NewDialogs/Listbox.h @@ -0,0 +1,26 @@ +#ifndef LISTBOX +#define LISTBOX + +#include + +using namespace std; + +#include "Item.h" + +class Listbox : public Item { +private: + vector list; + int selected; + int item_size; + void (*value_changed_func)(void *p); + void *p; +public: + Listbox(vector list, int item_size, SDL_Rect pos); + ~Listbox(); + void drawListbox(); + bool onMousePress(int x, int y); + void setValueChangedFunc(void (*value_changed_func)(void *p), void *p); + int getSelected(); +}; + +#endif diff --git a/NewDialogs/Scrollbar.cpp b/NewDialogs/Scrollbar.cpp new file mode 100644 index 0000000..900ad0b --- /dev/null +++ b/NewDialogs/Scrollbar.cpp @@ -0,0 +1,103 @@ +#include "Scrollbar.h" + +Scrollbar::Scrollbar(int min_value, int max_value, int value, SDL_Rect pos) : Item(pos) { + vertical = (pos.h > pos.w); + this->min_value = min_value; + this->max_value = max_value; + this->value = value; + bar_size = 18; + pressed = false; + value_changed_func = NULL; + setSurface(SDL_CreateSurface(getPos()->w, getPos()->h, SDL_GetPixelFormatForMasks(32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000))); + drawScrollbar(); +} + +Scrollbar::~Scrollbar() { + SDL_DestroySurface(getSurface()); +} + +void Scrollbar::drawScrollbar() { + SDL_Surface *surface = getSurface(); + int w = getPos()->w; + int h = getPos()->h; + + Uint32 *p = (Uint32 *) surface->pixels; + SDL_Color color; + for (int y = 0; y < h; y++) { + for (int x = 0; x < w; x++) { + int x_or_y = (vertical ? y : x); + bool bar_pos_test = (x_or_y > getBarPos() && x_or_y < getBarPos() + bar_size); + + if (y == 0 || y == h-1 || x == 0 || x == w-1 || bar_pos_test) { + color.r = 0; + color.g = 0; + color.b = 0; + } else { + color.r = 255; + color.g = 255; + color.b = 255; + } + *p = SDL_MapRGB(SDL_GetPixelFormatDetails(surface->format), NULL, color.r, color.g, color.b); + p++; + } + } +} + +bool Scrollbar::onMousePress(int x, int y) { + bool is_in_x = x > getPos()->x && x < getPos()->x + getPos()->w; + bool is_in_y = y > getPos()->y && y < getPos()->y + getPos()->h; + if (is_in_x && is_in_y) { + //setSurface(buttonDown); + mouse_offset = (vertical ? y : x) - getBarPos(); + pressed = true; + return true; + } + return false; +} + +void Scrollbar::onMouseRelease(int x, int y) { + //bool is_in_x = x > getPos()->x && x < getPos()->x + getPos()->w; + //bool is_in_y = y > getPos()->y && y < getPos()->y + getPos()->h; + //if (is_in_x && is_in_y && pressed) { + if (pressed) { + setValueByBarPos((vertical ? y : x) - mouse_offset); + drawScrollbar(); + if (value_changed_func) { + (*value_changed_func)(p); + } + } + //setSurface(buttonUp); + pressed = false; +} + +void Scrollbar::onMouseMove(int x, int y) { + if (pressed) { + setValueByBarPos((vertical ? y : x) - mouse_offset); + drawScrollbar(); + if (value_changed_func) + (*value_changed_func)(p); + } +} + +int Scrollbar::getBarPos() { + int w_or_h = (vertical ? getPos()->h : getPos()->w); + return (w_or_h - bar_size) * (value - min_value) / (max_value - min_value); +} + +void Scrollbar::setValueByBarPos(int pos) { + int w_or_h = (vertical ? getPos()->h : getPos()->w); + value = (max_value - min_value) * pos / (w_or_h - bar_size) + min_value; + if (value < min_value) + value = min_value; + if (value > max_value) + value = max_value; +} + +void Scrollbar::setValueChangedFunc(void (*value_changed_func)(void *p), void *p) { + this->value_changed_func = value_changed_func; + this->p = p; +} + +int Scrollbar::getValue() { + return value; +} diff --git a/NewDialogs/Scrollbar.h b/NewDialogs/Scrollbar.h new file mode 100644 index 0000000..2e381dc --- /dev/null +++ b/NewDialogs/Scrollbar.h @@ -0,0 +1,32 @@ +#ifndef SCROLLBAR +#define SCROLLBAR + +#include + +#include "Item.h" + +class Scrollbar : public Item { +private: + bool vertical; + int min_value; + int max_value; + int value; + int bar_size; + int mouse_offset; + bool pressed; + void (*value_changed_func)(void *p); + void *p; +public: + Scrollbar(int min_value, int max_value, int value, SDL_Rect pos); + ~Scrollbar(); + void drawScrollbar(); + bool onMousePress(int x, int y); + void onMouseRelease(int x, int y); + void onMouseMove(int x, int y); + int getBarPos(); + void setValueByBarPos(int pos); + void setValueChangedFunc(void (*value_changed_func)(void *p), void *p); + int getValue(); +}; + +#endif diff --git a/SDLHelpers.h b/SDLHelpers.h new file mode 100644 index 0000000..3743c7b --- /dev/null +++ b/SDLHelpers.h @@ -0,0 +1,45 @@ +#ifndef SDLHELPERS_H +#define SDLHELPERS_H + +#include +#include +#include +#include +#include +#include + +static const char *font_paths[] = {"C:/windows/fonts/", "/usr/share/fonts/TTF/", "./"}; +static const short font_path_count = 3; + +static SDL_Rect getRect(Sint16 x, Sint16 y, Uint16 w, Uint16 h) { + SDL_Rect rect; + rect.x = x; + rect.y = y; + rect.w = w; + rect.h = h; + return rect; +} + +static SDL_Color getColor(Uint8 r, Uint8 g, Uint8 b) { + SDL_Color color; + color.r = r; + color.g = g; + color.b = b; + return color; +} + +static TTF_Font *openFont(std::vector fonts, int size) { + TTF_Font *font = NULL; + for (int x = 0; x < fonts.size(); x++) { + for (int y = 0; y < font_path_count; y++) { + std::string val(font_paths[y]); + val.append(fonts[x]); + font = TTF_OpenFont(val.c_str(), size); + if (font) + return font; + } + } + return NULL; +} + +#endif diff --git a/Sound.cpp b/Sound.cpp new file mode 100644 index 0000000..02f33b5 --- /dev/null +++ b/Sound.cpp @@ -0,0 +1,47 @@ +#include "Sound.h" + +Sound::Sound() { + is_open = false; + stream = NULL; +} + +void Sound::setSound(SoundData *sound_data) { + if (sound_data->len && !is_open) { + //SDL_Log("audio open, len %d", sound_data->len); + stream = SDL_OpenAudioDeviceStream(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &sound_data->spec, &streamCb, sound_data); + //stream = SDL_OpenAudioDeviceStream(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &sound_data.spec, NULL, NULL); + if (stream) { + is_open = true; + } else { + SDL_Log("Could not open audio stream %s", SDL_GetError()); + } + } + if (stream && is_open) { + if (sound_data->len) { + SDL_SetAudioStreamGetCallback(stream, streamCb, sound_data); + SDL_ResumeAudioStreamDevice(stream); + } else { + SDL_SetAudioStreamGetCallback(stream, NULL, sound_data); + } + /*int len = SDL_GetAudioStreamQueued(stream); + SDL_Log("LEN %d paused %d", len); + if (!len) { + SDL_PutAudioStreamData(stream, sound_data.buf, sound_data.len); + }*/ + } +} + +void Sound::streamCb(void *userdata, SDL_AudioStream *stream, int additional_amount, int total_amount) { + SoundData* sound_data = (SoundData *) userdata; + if ((!sound_data->is_played || sound_data->loop) && additional_amount) { + //SDL_Log("LEN2 %d total_amount %d additional_amount %d", sound_data->len, total_amount, additional_amount); + SDL_PutAudioStreamData(stream, sound_data->buf, sound_data->len); + sound_data->is_played = true; + } +} + +void Sound::closeSound() { + SDL_DestroyAudioStream(stream); + stream = NULL; + is_open = false; +} diff --git a/Sound.h b/Sound.h new file mode 100644 index 0000000..485dc39 --- /dev/null +++ b/Sound.h @@ -0,0 +1,20 @@ +#ifndef SOUND_H +#define SOUND_H + +#include +#include + +#include "SoundData.h" + +class Sound { + private: + SDL_AudioStream *stream; + bool is_open; + public: + Sound(); + void setSound(SoundData *sound_data); + static void streamCb(void *userdata, SDL_AudioStream *stream, int additional_amount, int total_amount); + void closeSound(); +}; + +#endif diff --git a/SoundData.h b/SoundData.h new file mode 100644 index 0000000..186e921 --- /dev/null +++ b/SoundData.h @@ -0,0 +1,15 @@ +#ifndef SOUND_DATA_H +#define SOUND_DATA_H + +#include + +class SoundData { + public: + bool is_played; + bool loop; + SDL_AudioSpec spec; + Uint8 *buf; + Uint32 len; +}; + +#endif diff --git a/embed.h b/embed.h new file mode 100644 index 0000000..a248e9f --- /dev/null +++ b/embed.h @@ -0,0 +1,427 @@ + +enum skin_name { Tavallinen, Alppisusi, Chibi }; +enum skin_state { falling, haukahdus, hoksaa, hyppaa, kiali, laukka, laukka2, paikka, pissaus, platsahtaa, putoo, pyorii, pyoriivasemmalle, roikkuu, rouskutus }; + +// create with echo $(for n in $(find skin -name "*.png"; find skin -name "*.wav"; find skin -name "*.tsk"); do xxd -i $n; done) > embed_data.h +#include "embed_data.h" + +#include +#include +#include +#include + +using namespace std; + +class embed_data { + public: + unsigned char *data; + unsigned int len; +}; + +embed_data skin_Tavallinen_falling[4] = { + {skin_Tavallinen_falling_1_png, skin_Tavallinen_falling_1_png_len}, + {skin_Tavallinen_falling_2_png, skin_Tavallinen_falling_2_png_len}, + {skin_Tavallinen_falling_3_png, skin_Tavallinen_falling_3_png_len}, + {skin_Tavallinen_falling_4_png, skin_Tavallinen_falling_4_png_len} +}; +embed_data skin_Tavallinen_haukahdus[4] = { + {skin_Tavallinen_haukahdus_1_png, skin_Tavallinen_haukahdus_1_png_len}, + {skin_Tavallinen_haukahdus_2_png, skin_Tavallinen_haukahdus_2_png_len}, + {skin_Tavallinen_haukahdus_3_png, skin_Tavallinen_haukahdus_3_png_len}, + {skin_Tavallinen_haukahdus_4_png, skin_Tavallinen_haukahdus_4_png_len} +}; +embed_data skin_Tavallinen_hoksaa[4] = { + {skin_Tavallinen_hoksaa_1_png, skin_Tavallinen_hoksaa_1_png_len}, + {skin_Tavallinen_hoksaa_2_png, skin_Tavallinen_hoksaa_2_png_len}, + {skin_Tavallinen_hoksaa_3_png, skin_Tavallinen_hoksaa_3_png_len}, + {skin_Tavallinen_hoksaa_4_png, skin_Tavallinen_hoksaa_4_png_len} +}; +embed_data skin_Tavallinen_hyppaa[4] = { + {skin_Tavallinen_hyppaa_1_png, skin_Tavallinen_hyppaa_1_png_len}, + {skin_Tavallinen_hyppaa_2_png, skin_Tavallinen_hyppaa_2_png_len}, + {skin_Tavallinen_hyppaa_3_png, skin_Tavallinen_hyppaa_3_png_len}, + {skin_Tavallinen_hyppaa_4_png, skin_Tavallinen_hyppaa_4_png_len} +}; +embed_data skin_Tavallinen_kiali[4] = { + {skin_Tavallinen_kiali_1_png, skin_Tavallinen_kiali_1_png_len}, + {skin_Tavallinen_kiali_2_png, skin_Tavallinen_kiali_2_png_len}, + {skin_Tavallinen_kiali_3_png, skin_Tavallinen_kiali_3_png_len}, + {skin_Tavallinen_kiali_4_png, skin_Tavallinen_kiali_4_png_len} +}; +embed_data skin_Tavallinen_laukka[6] = { + {skin_Tavallinen_laukka_1_png, skin_Tavallinen_laukka_1_png_len}, + {skin_Tavallinen_laukka_2_png, skin_Tavallinen_laukka_2_png_len}, + {skin_Tavallinen_laukka_3_png, skin_Tavallinen_laukka_3_png_len}, + {skin_Tavallinen_laukka_4_png, skin_Tavallinen_laukka_4_png_len}, + {skin_Tavallinen_laukka_5_png, skin_Tavallinen_laukka_5_png_len}, + {skin_Tavallinen_laukka_6_png, skin_Tavallinen_laukka_6_png_len} +}; +embed_data skin_Tavallinen_laukka2[6] = { + {skin_Tavallinen_laukka2_1_png, skin_Tavallinen_laukka2_1_png_len}, + {skin_Tavallinen_laukka2_2_png, skin_Tavallinen_laukka2_2_png_len}, + {skin_Tavallinen_laukka2_3_png, skin_Tavallinen_laukka2_3_png_len}, + {skin_Tavallinen_laukka2_4_png, skin_Tavallinen_laukka2_4_png_len}, + {skin_Tavallinen_laukka2_5_png, skin_Tavallinen_laukka2_5_png_len}, + {skin_Tavallinen_laukka2_6_png, skin_Tavallinen_laukka2_6_png_len} +}; +embed_data skin_Tavallinen_paikka[4] = { + {skin_Tavallinen_paikka_1_png, skin_Tavallinen_paikka_1_png_len}, + {skin_Tavallinen_paikka_2_png, skin_Tavallinen_paikka_2_png_len}, + {skin_Tavallinen_paikka_3_png, skin_Tavallinen_paikka_3_png_len}, + {skin_Tavallinen_paikka_4_png, skin_Tavallinen_paikka_4_png_len} +}; +embed_data skin_Tavallinen_pissaus[7] = { + {skin_Tavallinen_pissaus_1_png, skin_Tavallinen_pissaus_1_png_len}, + {skin_Tavallinen_pissaus_2_png, skin_Tavallinen_pissaus_2_png_len}, + {skin_Tavallinen_pissaus_3_png, skin_Tavallinen_pissaus_3_png_len}, + {skin_Tavallinen_pissaus_4_png, skin_Tavallinen_pissaus_4_png_len}, + {skin_Tavallinen_pissaus_5_png, skin_Tavallinen_pissaus_5_png_len}, + {skin_Tavallinen_pissaus_6_png, skin_Tavallinen_pissaus_6_png_len}, + {skin_Tavallinen_pissaus_7_png, skin_Tavallinen_pissaus_7_png_len}, +}; +embed_data skin_Tavallinen_platsahtaa[4] = { + {skin_Tavallinen_platsahtaa_1_png, skin_Tavallinen_platsahtaa_1_png_len}, + {skin_Tavallinen_platsahtaa_2_png, skin_Tavallinen_platsahtaa_2_png_len}, + {skin_Tavallinen_platsahtaa_3_png, skin_Tavallinen_platsahtaa_3_png_len}, + {skin_Tavallinen_platsahtaa_4_png, skin_Tavallinen_platsahtaa_4_png_len} +}; +embed_data skin_Tavallinen_putoo[4] = { + {skin_Tavallinen_putoo_1_png, skin_Tavallinen_putoo_1_png_len}, + {skin_Tavallinen_putoo_2_png, skin_Tavallinen_putoo_2_png_len}, + {skin_Tavallinen_putoo_3_png, skin_Tavallinen_putoo_3_png_len}, + {skin_Tavallinen_putoo_4_png, skin_Tavallinen_putoo_4_png_len} +}; +embed_data skin_Tavallinen_pyorii[4] = { + {skin_Tavallinen_pyorii_1_png, skin_Tavallinen_pyorii_1_png_len}, + {skin_Tavallinen_pyorii_2_png, skin_Tavallinen_pyorii_2_png_len}, + {skin_Tavallinen_pyorii_3_png, skin_Tavallinen_pyorii_3_png_len}, + {skin_Tavallinen_pyorii_4_png, skin_Tavallinen_pyorii_4_png_len} +}; +embed_data skin_Tavallinen_pyoriivasemmalle[4] = { + {skin_Tavallinen_pyoriivasemmalle_1_png, skin_Tavallinen_pyoriivasemmalle_1_png_len}, + {skin_Tavallinen_pyoriivasemmalle_2_png, skin_Tavallinen_pyoriivasemmalle_2_png_len}, + {skin_Tavallinen_pyoriivasemmalle_3_png, skin_Tavallinen_pyoriivasemmalle_3_png_len}, + {skin_Tavallinen_pyoriivasemmalle_4_png, skin_Tavallinen_pyoriivasemmalle_4_png_len} +}; +embed_data skin_Tavallinen_roikkuu[1] = { + {skin_Tavallinen_roikkuu_1_png, skin_Tavallinen_roikkuu_1_png_len}, +}; +embed_data skin_Tavallinen_rouskutus[4] = { + {skin_Tavallinen_rouskutus_1_png, skin_Tavallinen_rouskutus_1_png_len}, + {skin_Tavallinen_rouskutus_2_png, skin_Tavallinen_rouskutus_2_png_len}, + {skin_Tavallinen_rouskutus_3_png, skin_Tavallinen_rouskutus_3_png_len}, + {skin_Tavallinen_rouskutus_4_png, skin_Tavallinen_rouskutus_4_png_len} +}; + +embed_data *skin_Tavallinen[15] = { + skin_Tavallinen_falling, + skin_Tavallinen_haukahdus, + skin_Tavallinen_hoksaa, + skin_Tavallinen_hyppaa, + skin_Tavallinen_kiali, + skin_Tavallinen_laukka, + skin_Tavallinen_laukka2, + skin_Tavallinen_paikka, + skin_Tavallinen_pissaus, + skin_Tavallinen_platsahtaa, + skin_Tavallinen_putoo, + skin_Tavallinen_pyorii, + skin_Tavallinen_pyoriivasemmalle, + skin_Tavallinen_roikkuu, + skin_Tavallinen_rouskutus +}; + +embed_data skin_Alppisusi_falling[4] = { + {skin_Alppisusi_falling_1_png, skin_Alppisusi_falling_1_png_len}, + {skin_Alppisusi_falling_2_png, skin_Alppisusi_falling_2_png_len}, + {skin_Alppisusi_falling_3_png, skin_Alppisusi_falling_3_png_len}, + {skin_Alppisusi_falling_4_png, skin_Alppisusi_falling_4_png_len} +}; +embed_data skin_Alppisusi_haukahdus[4] = { + {skin_Alppisusi_haukahdus_1_png, skin_Alppisusi_haukahdus_1_png_len}, + {skin_Alppisusi_haukahdus_2_png, skin_Alppisusi_haukahdus_2_png_len}, + {skin_Alppisusi_haukahdus_3_png, skin_Alppisusi_haukahdus_3_png_len}, + {skin_Alppisusi_haukahdus_4_png, skin_Alppisusi_haukahdus_4_png_len} +}; +embed_data skin_Alppisusi_hoksaa[4] = { + {skin_Alppisusi_hoksaa_1_png, skin_Alppisusi_hoksaa_1_png_len}, + {skin_Alppisusi_hoksaa_2_png, skin_Alppisusi_hoksaa_2_png_len}, + {skin_Alppisusi_hoksaa_3_png, skin_Alppisusi_hoksaa_3_png_len}, + {skin_Alppisusi_hoksaa_4_png, skin_Alppisusi_hoksaa_4_png_len} +}; +embed_data skin_Alppisusi_hyppaa[4] = { + {skin_Alppisusi_hyppaa_1_png, skin_Alppisusi_hyppaa_1_png_len}, + {skin_Alppisusi_hyppaa_2_png, skin_Alppisusi_hyppaa_2_png_len}, + {skin_Alppisusi_hyppaa_3_png, skin_Alppisusi_hyppaa_3_png_len}, + {skin_Alppisusi_hyppaa_4_png, skin_Alppisusi_hyppaa_4_png_len} +}; +embed_data skin_Alppisusi_kiali[4] = { + {skin_Alppisusi_kiali_1_png, skin_Alppisusi_kiali_1_png_len}, + {skin_Alppisusi_kiali_2_png, skin_Alppisusi_kiali_2_png_len}, + {skin_Alppisusi_kiali_3_png, skin_Alppisusi_kiali_3_png_len}, + {skin_Alppisusi_kiali_4_png, skin_Alppisusi_kiali_4_png_len} +}; +embed_data skin_Alppisusi_laukka[6] = { + {skin_Alppisusi_laukka_1_png, skin_Alppisusi_laukka_1_png_len}, + {skin_Alppisusi_laukka_2_png, skin_Alppisusi_laukka_2_png_len}, + {skin_Alppisusi_laukka_3_png, skin_Alppisusi_laukka_3_png_len}, + {skin_Alppisusi_laukka_4_png, skin_Alppisusi_laukka_4_png_len}, + {skin_Alppisusi_laukka_5_png, skin_Alppisusi_laukka_5_png_len}, + {skin_Alppisusi_laukka_6_png, skin_Alppisusi_laukka_6_png_len} +}; +embed_data skin_Alppisusi_laukka2[6] = { + {skin_Alppisusi_laukka2_1_png, skin_Alppisusi_laukka2_1_png_len}, + {skin_Alppisusi_laukka2_2_png, skin_Alppisusi_laukka2_2_png_len}, + {skin_Alppisusi_laukka2_3_png, skin_Alppisusi_laukka2_3_png_len}, + {skin_Alppisusi_laukka2_4_png, skin_Alppisusi_laukka2_4_png_len}, + {skin_Alppisusi_laukka2_5_png, skin_Alppisusi_laukka2_5_png_len}, + {skin_Alppisusi_laukka2_6_png, skin_Alppisusi_laukka2_6_png_len} +}; +embed_data skin_Alppisusi_paikka[4] = { + {skin_Alppisusi_paikka_1_png, skin_Alppisusi_paikka_1_png_len}, + {skin_Alppisusi_paikka_2_png, skin_Alppisusi_paikka_2_png_len}, + {skin_Alppisusi_paikka_3_png, skin_Alppisusi_paikka_3_png_len}, + {skin_Alppisusi_paikka_4_png, skin_Alppisusi_paikka_4_png_len} +}; +embed_data skin_Alppisusi_pissaus[7] = { + {skin_Alppisusi_pissaus_1_png, skin_Alppisusi_pissaus_1_png_len}, + {skin_Alppisusi_pissaus_2_png, skin_Alppisusi_pissaus_2_png_len}, + {skin_Alppisusi_pissaus_3_png, skin_Alppisusi_pissaus_3_png_len}, + {skin_Alppisusi_pissaus_4_png, skin_Alppisusi_pissaus_4_png_len}, + {skin_Alppisusi_pissaus_5_png, skin_Alppisusi_pissaus_5_png_len}, + {skin_Alppisusi_pissaus_6_png, skin_Alppisusi_pissaus_6_png_len}, + {skin_Alppisusi_pissaus_7_png, skin_Alppisusi_pissaus_7_png_len}, +}; +embed_data skin_Alppisusi_platsahtaa[4] = { + {skin_Alppisusi_platsahtaa_1_png, skin_Alppisusi_platsahtaa_1_png_len}, + {skin_Alppisusi_platsahtaa_2_png, skin_Alppisusi_platsahtaa_2_png_len}, + {skin_Alppisusi_platsahtaa_3_png, skin_Alppisusi_platsahtaa_3_png_len}, + {skin_Alppisusi_platsahtaa_4_png, skin_Alppisusi_platsahtaa_4_png_len} +}; +embed_data skin_Alppisusi_putoo[4] = { + {skin_Alppisusi_putoo_1_png, skin_Alppisusi_putoo_1_png_len}, + {skin_Alppisusi_putoo_2_png, skin_Alppisusi_putoo_2_png_len}, + {skin_Alppisusi_putoo_3_png, skin_Alppisusi_putoo_3_png_len}, + {skin_Alppisusi_putoo_4_png, skin_Alppisusi_putoo_4_png_len} +}; +embed_data skin_Alppisusi_pyorii[4] = { + {skin_Alppisusi_pyorii_1_png, skin_Alppisusi_pyorii_1_png_len}, + {skin_Alppisusi_pyorii_2_png, skin_Alppisusi_pyorii_2_png_len}, + {skin_Alppisusi_pyorii_3_png, skin_Alppisusi_pyorii_3_png_len}, + {skin_Alppisusi_pyorii_4_png, skin_Alppisusi_pyorii_4_png_len} +}; +embed_data skin_Alppisusi_pyoriivasemmalle[4] = { + {skin_Alppisusi_pyoriivasemmalle_1_png, skin_Alppisusi_pyoriivasemmalle_1_png_len}, + {skin_Alppisusi_pyoriivasemmalle_2_png, skin_Alppisusi_pyoriivasemmalle_2_png_len}, + {skin_Alppisusi_pyoriivasemmalle_3_png, skin_Alppisusi_pyoriivasemmalle_3_png_len}, + {skin_Alppisusi_pyoriivasemmalle_4_png, skin_Alppisusi_pyoriivasemmalle_4_png_len} +}; +embed_data skin_Alppisusi_roikkuu[1] = { + {skin_Alppisusi_roikkuu_1_png, skin_Alppisusi_roikkuu_1_png_len}, +}; +embed_data skin_Alppisusi_rouskutus[4] = { + {skin_Alppisusi_rouskutus_1_png, skin_Alppisusi_rouskutus_1_png_len}, + {skin_Alppisusi_rouskutus_2_png, skin_Alppisusi_rouskutus_2_png_len}, + {skin_Alppisusi_rouskutus_3_png, skin_Alppisusi_rouskutus_3_png_len}, + {skin_Alppisusi_rouskutus_4_png, skin_Alppisusi_rouskutus_4_png_len} +}; + +embed_data *skin_Alppisusi[15] = { + skin_Alppisusi_falling, + skin_Alppisusi_haukahdus, + skin_Alppisusi_hoksaa, + skin_Alppisusi_hyppaa, + skin_Alppisusi_kiali, + skin_Alppisusi_laukka, + skin_Alppisusi_laukka2, + skin_Alppisusi_paikka, + skin_Alppisusi_pissaus, + skin_Alppisusi_platsahtaa, + skin_Alppisusi_putoo, + skin_Alppisusi_pyorii, + skin_Alppisusi_pyoriivasemmalle, + skin_Alppisusi_roikkuu, + skin_Alppisusi_rouskutus +}; + +embed_data skin_Chibi_falling[4] = { + {skin_Chibi_falling_1_png, skin_Chibi_falling_1_png_len}, + {skin_Chibi_falling_2_png, skin_Chibi_falling_2_png_len}, + {skin_Chibi_falling_3_png, skin_Chibi_falling_3_png_len}, + {skin_Chibi_falling_4_png, skin_Chibi_falling_4_png_len} +}; +embed_data skin_Chibi_haukahdus[4] = { + {skin_Chibi_haukahdus_1_png, skin_Chibi_haukahdus_1_png_len}, + {skin_Chibi_haukahdus_2_png, skin_Chibi_haukahdus_2_png_len}, + {skin_Chibi_haukahdus_3_png, skin_Chibi_haukahdus_3_png_len}, + {skin_Chibi_haukahdus_4_png, skin_Chibi_haukahdus_4_png_len} +}; +embed_data skin_Chibi_hoksaa[4] = { + {skin_Chibi_hoksaa_1_png, skin_Chibi_hoksaa_1_png_len}, + {skin_Chibi_hoksaa_2_png, skin_Chibi_hoksaa_2_png_len}, + {skin_Chibi_hoksaa_3_png, skin_Chibi_hoksaa_3_png_len}, + {skin_Chibi_hoksaa_4_png, skin_Chibi_hoksaa_4_png_len} +}; +embed_data skin_Chibi_hyppaa[4] = { + {skin_Chibi_hyppaa_1_png, skin_Chibi_hyppaa_1_png_len}, + {skin_Chibi_hyppaa_2_png, skin_Chibi_hyppaa_2_png_len}, + {skin_Chibi_hyppaa_3_png, skin_Chibi_hyppaa_3_png_len}, + {skin_Chibi_hyppaa_4_png, skin_Chibi_hyppaa_4_png_len} +}; +embed_data skin_Chibi_kiali[4] = { + {skin_Chibi_kiali_1_png, skin_Chibi_kiali_1_png_len}, + {skin_Chibi_kiali_2_png, skin_Chibi_kiali_2_png_len}, + {skin_Chibi_kiali_3_png, skin_Chibi_kiali_3_png_len}, + {skin_Chibi_kiali_4_png, skin_Chibi_kiali_4_png_len} +}; +embed_data skin_Chibi_laukka[6] = { + {skin_Chibi_laukka_1_png, skin_Chibi_laukka_1_png_len}, + {skin_Chibi_laukka_2_png, skin_Chibi_laukka_2_png_len}, + {skin_Chibi_laukka_3_png, skin_Chibi_laukka_3_png_len}, + {skin_Chibi_laukka_4_png, skin_Chibi_laukka_4_png_len}, + {skin_Chibi_laukka_5_png, skin_Chibi_laukka_5_png_len}, + {skin_Chibi_laukka_6_png, skin_Chibi_laukka_6_png_len} +}; +embed_data skin_Chibi_laukka2[6] = { + {skin_Chibi_laukka2_1_png, skin_Chibi_laukka2_1_png_len}, + {skin_Chibi_laukka2_2_png, skin_Chibi_laukka2_2_png_len}, + {skin_Chibi_laukka2_3_png, skin_Chibi_laukka2_3_png_len}, + {skin_Chibi_laukka2_4_png, skin_Chibi_laukka2_4_png_len}, + {skin_Chibi_laukka2_5_png, skin_Chibi_laukka2_5_png_len}, + {skin_Chibi_laukka2_6_png, skin_Chibi_laukka2_6_png_len} +}; +embed_data skin_Chibi_paikka[4] = { + {skin_Chibi_paikka_1_png, skin_Chibi_paikka_1_png_len}, + {skin_Chibi_paikka_2_png, skin_Chibi_paikka_2_png_len}, + {skin_Chibi_paikka_3_png, skin_Chibi_paikka_3_png_len}, + {skin_Chibi_paikka_4_png, skin_Chibi_paikka_4_png_len} +}; +embed_data skin_Chibi_pissaus[7] = { + {skin_Chibi_pissaus_1_png, skin_Chibi_pissaus_1_png_len}, + {skin_Chibi_pissaus_2_png, skin_Chibi_pissaus_2_png_len}, + {skin_Chibi_pissaus_3_png, skin_Chibi_pissaus_3_png_len}, + {skin_Chibi_pissaus_4_png, skin_Chibi_pissaus_4_png_len}, + {skin_Chibi_pissaus_5_png, skin_Chibi_pissaus_5_png_len}, + {skin_Chibi_pissaus_6_png, skin_Chibi_pissaus_6_png_len}, + {skin_Chibi_pissaus_7_png, skin_Chibi_pissaus_7_png_len}, +}; +embed_data skin_Chibi_platsahtaa[4] = { + {skin_Chibi_platsahtaa_1_png, skin_Chibi_platsahtaa_1_png_len}, + {skin_Chibi_platsahtaa_2_png, skin_Chibi_platsahtaa_2_png_len}, + {skin_Chibi_platsahtaa_3_png, skin_Chibi_platsahtaa_3_png_len}, + {skin_Chibi_platsahtaa_4_png, skin_Chibi_platsahtaa_4_png_len} +}; +embed_data skin_Chibi_putoo[4] = { + {skin_Chibi_putoo_1_png, skin_Chibi_putoo_1_png_len}, + {skin_Chibi_putoo_2_png, skin_Chibi_putoo_2_png_len}, + {skin_Chibi_putoo_3_png, skin_Chibi_putoo_3_png_len}, + {skin_Chibi_putoo_4_png, skin_Chibi_putoo_4_png_len} +}; +embed_data skin_Chibi_pyorii[4] = { + {skin_Chibi_pyorii_1_png, skin_Chibi_pyorii_1_png_len}, + {skin_Chibi_pyorii_2_png, skin_Chibi_pyorii_2_png_len}, + {skin_Chibi_pyorii_3_png, skin_Chibi_pyorii_3_png_len}, + {skin_Chibi_pyorii_4_png, skin_Chibi_pyorii_4_png_len} +}; +embed_data skin_Chibi_pyoriivasemmalle[4] = { + {skin_Chibi_pyoriivasemmalle_1_png, skin_Chibi_pyoriivasemmalle_1_png_len}, + {skin_Chibi_pyoriivasemmalle_2_png, skin_Chibi_pyoriivasemmalle_2_png_len}, + {skin_Chibi_pyoriivasemmalle_3_png, skin_Chibi_pyoriivasemmalle_3_png_len}, + {skin_Chibi_pyoriivasemmalle_4_png, skin_Chibi_pyoriivasemmalle_4_png_len} +}; +embed_data skin_Chibi_roikkuu[1] = { + {skin_Chibi_roikkuu_1_png, skin_Chibi_roikkuu_1_png_len}, +}; +embed_data skin_Chibi_rouskutus[4] = { + {skin_Chibi_rouskutus_1_png, skin_Chibi_rouskutus_1_png_len}, + {skin_Chibi_rouskutus_2_png, skin_Chibi_rouskutus_2_png_len}, + {skin_Chibi_rouskutus_3_png, skin_Chibi_rouskutus_3_png_len}, + {skin_Chibi_rouskutus_4_png, skin_Chibi_rouskutus_4_png_len} +}; + +embed_data *skin_Chibi[15] = { + skin_Chibi_falling, + skin_Chibi_haukahdus, + skin_Chibi_hoksaa, + skin_Chibi_hyppaa, + skin_Chibi_kiali, + skin_Chibi_laukka, + skin_Chibi_laukka2, + skin_Chibi_paikka, + skin_Chibi_pissaus, + skin_Chibi_platsahtaa, + skin_Chibi_putoo, + skin_Chibi_pyorii, + skin_Chibi_pyoriivasemmalle, + skin_Chibi_roikkuu, + skin_Chibi_rouskutus +}; + +map img_name_map = { + {"falling", 0}, + {"haukahdus", 1}, + {"hoksaa", 2}, + {"hyppaa", 3}, + {"kiali", 4}, + {"laukka", 5}, + {"laukka2", 6}, + {"paikka", 7}, + {"pissaus", 8}, + {"platsahtaa", 9}, + {"putoo", 10}, + {"pyorii", 11}, + {"pyoriivasemmalle", 12}, + {"roikkuu", 13}, + {"rouskutus", 14} +}; + +class SkinsEmbed { + public: + embed_data *getSkin(string skin, string img_name) { + //return NULL; + if (skin == "Tavallinen") { + return skin_Tavallinen[img_name_map[img_name]]; + } else if (skin == "Alppisusi") { + return skin_Alppisusi[img_name_map[img_name]]; + } else if (skin == "Chibi") { + return skin_Chibi[img_name_map[img_name]]; + } + return NULL; + } + + pair getSound(string skin, string img_name) { + //return make_pair((unsigned char *) NULL, 0); + if (skin == "Tavallinen") { + if (img_name == "haukahdus") { + return make_pair(skin_Tavallinen_haukahdus_roh2_wav, skin_Tavallinen_haukahdus_roh2_wav_len); + } else if (img_name == "platsahtaa") { + return make_pair(skin_Tavallinen_platsahtaa_tomsmaahan_wav, skin_Tavallinen_platsahtaa_tomsmaahan_wav_len); + } + } else if (skin == "Alppisusi") { + if (img_name == "haukahdus") { + return make_pair(skin_Alppisusi_haukahdus_roh_wav, skin_Alppisusi_haukahdus_roh_wav_len); + } else if (img_name == "platsahtaa") { + return make_pair(skin_Alppisusi_platsahtaa_tomsmaahan_wav, skin_Alppisusi_platsahtaa_tomsmaahan_wav_len); + } + } else if (skin == "Chibi") { + if (img_name == "haukahdus") { + return make_pair(skin_Chibi_haukahdus_roh_wav, skin_Chibi_haukahdus_roh_wav_len); + } else if (img_name == "platsahtaa") { + return make_pair(skin_Chibi_platsahtaa_tomsmaahan_wav, skin_Chibi_platsahtaa_tomsmaahan_wav_len); + } + } + return make_pair((unsigned char *) NULL, 0); + } + + string getParams(string skin) { + //return ""; + if (skin == "Tavallinen") { + return string((char *)skin_Tavallinen_tsk, skin_Tavallinen_tsk_len); + } else if (skin == "Alppisusi") { + return string((char *)skin_Alppisusi_tsk, skin_Alppisusi_tsk_len); + } else if (skin == "Chibi") { + return string((char *)skin_Chibi_tsk, skin_Chibi_tsk_len); + } + return ""; + } +}; diff --git a/icon.ico b/icon.ico new file mode 100644 index 0000000..efae6ef Binary files /dev/null and b/icon.ico differ diff --git a/icon.rc b/icon.rc new file mode 100644 index 0000000..da47ee1 --- /dev/null +++ b/icon.rc @@ -0,0 +1 @@ +id ICON "icon.ico" diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..30b9eab --- /dev/null +++ b/main.cpp @@ -0,0 +1,192 @@ +#include +#include +#include + +#include "Animal.h" +#include "NewDialogs/DlgMainMenu.h" +#include "Sound.h" + +using namespace std; + +int main(int argc, char **argv) { + if (!SDL_Init(SDL_INIT_AUDIO | SDL_INIT_VIDEO)) { + SDL_Log("Could not init SDL %s", SDL_GetError()); + } + + if(!TTF_Init()) { + SDL_Log("TTF_Init: %s", SDL_GetError()); + return 1; + } + + SDL_Window *sdl_window = SDL_CreateWindow("Rousku", 10, 10, SDL_WINDOW_TRANSPARENT | SDL_WINDOW_BORDERLESS | SDL_WINDOW_UTILITY | SDL_WINDOW_ALWAYS_ON_TOP); + if (sdl_window == NULL) { + SDL_Log("error creating window"); + return 1; + } + SDL_WindowID sdl_window_id = SDL_GetWindowID(sdl_window); + + SDL_Window *sdl_menu_win = SDL_CreateWindow("Rouskun asetukset", 10, 10, SDL_WINDOW_HIDDEN); + if (sdl_menu_win == NULL) { + SDL_Log("error creating window"); + return 1; + } + + SDL_Renderer *sdl_renderer = SDL_CreateRenderer(sdl_window, NULL); + if (sdl_renderer == NULL) { + SDL_Log("error creating renderer"); + } + + SDL_Renderer *sdl_menu_renderer = SDL_CreateRenderer(sdl_menu_win, NULL); + if (sdl_menu_renderer == NULL) { + SDL_Log("error creating renderer"); + } + + Sound sound; + + bool press = false; + Uint64 prev_press_ticks = 0; + float mouse_win_rel_x, mouse_win_rel_y; + SDL_Rect old_menu_size = { 10, 10, 0, 0 }; + DlgMainMenu *dlg_menu = new DlgMainMenu(); + + Animal rousku(dlg_menu->getSkin()); + + int num_displays; + SDL_DisplayID *displays = SDL_GetDisplays(&num_displays); + SDL_Log("Found %d display(s)", num_displays); + for (unsigned i = 0; i < num_displays; i++) { + SDL_Log("Display %d", displays[i]); + const SDL_DisplayMode *dm = SDL_GetCurrentDisplayMode(displays[i]); + if (!dm) { + SDL_Log("Couldn't get display mode: %s\n", SDL_GetError()); + return 1; + } + + SDL_Log("screen w %d h %d", dm->w, dm->h); + rousku.disp_pos.w = dm->w; + rousku.disp_pos.h = dm->h; + rousku.disp_pos.x = dm->w / 2; + rousku.disp_pos.y = dm->h / 2; + } + + // Get MOUSE_DOWN event when clicking unfocused window + SDL_SetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1"); + + while (!dlg_menu->isAppExit()) { + SDL_Event event; + SDL_zero(event); + while (SDL_PollEvent(&event)) { + if (event.type == SDL_EVENT_KEY_DOWN) { + } else if (event.type == SDL_EVENT_KEY_UP) { + } else if (event.type == SDL_EVENT_QUIT) { + dlg_menu->setAppExit(true); + } else if (event.type == SDL_EVENT_MOUSE_BUTTON_DOWN) { + if (event.button.windowID == sdl_window_id) { + SDL_Log("btn down"); + rousku.setSpecialState(hang); + press = true; + mouse_win_rel_x = event.button.x; + mouse_win_rel_y = event.button.y; + Uint64 ticks = SDL_GetTicks(); + + // show menu if double clicking + if (ticks - prev_press_ticks < 300) { + dlg_menu->setExit(false); + } + prev_press_ticks = ticks; + } else { + dlg_menu->onMousePress(event.button.x, event.button.y); + } + } else if (event.type == SDL_EVENT_MOUSE_BUTTON_UP) { + if (press) { + SDL_Log("btn up"); + rousku.setSpecialState(drop); + rousku.resetTimes(SDL_GetTicks()); + press = false; + } else { + dlg_menu->onMouseRelease(event.button.x, event.button.y); + } + } else if (event.type == SDL_EVENT_MOUSE_MOTION) { + if (event.button.windowID == sdl_window_id) { + if (press) { + float motion_x, motion_y; + SDL_GetGlobalMouseState(&motion_x, &motion_y); + rousku.disp_pos.x = motion_x - mouse_win_rel_x; + rousku.disp_pos.y = motion_y - mouse_win_rel_y; + } else if (dlg_menu->isRunAwayFromMouse()) { + rousku.shouldRunAway(event.motion.x < (float) rousku.getImage()->w / 2 ? 1 : -1); // selecting direction to run in parameter + } + } + } + } + + string changed_setting = dlg_menu->getChangedSetting(); + if (changed_setting == "skin_list") { + rousku.readSkin(dlg_menu->getSkin()); + rousku.setSpecialState(drop); + } + Uint64 delay = rousku.step(SDL_GetTicks(), press); + if (rousku.hasStateChanged()) { + sound.closeSound(); // so it will be reloaded with right format + } + SDL_Surface *animal_sfe = rousku.getImage(); + + SDL_Texture *sdl_texture = SDL_CreateTexture(sdl_renderer, animal_sfe->format, SDL_TEXTUREACCESS_STREAMING, animal_sfe->w, animal_sfe->h); + if (!sdl_texture) { + SDL_Log("Couldn't create texture: %s\n", SDL_GetError()); + return 1; + } + + SDL_SetWindowPosition(sdl_window, rousku.disp_pos.x, rousku.disp_pos.y); + SDL_SetWindowSize(sdl_window, animal_sfe->w, animal_sfe->h); + SDL_SetWindowShape(sdl_window, animal_sfe); + + SDL_UpdateTexture(sdl_texture, NULL, animal_sfe->pixels, animal_sfe->pitch); + SDL_RenderClear(sdl_renderer); + SDL_RenderTexture(sdl_renderer, sdl_texture, NULL, NULL); + SDL_RenderPresent(sdl_renderer); + + SDL_DestroyTexture(sdl_texture); + if (dlg_menu->isExit()) { + SDL_HideWindow(sdl_menu_win); + } else { + dlg_menu->setPreviewSurface(rousku.getPreviewSurface()); + + SDL_Surface *dlg_menu_sfe = dlg_menu->getSurface(); + SDL_Texture *sdl_menu_texture = SDL_CreateTexture(sdl_menu_renderer, dlg_menu_sfe->format, SDL_TEXTUREACCESS_STREAMING, dlg_menu_sfe->w, dlg_menu_sfe->h); + if (!sdl_menu_texture) { + SDL_Log("Couldn't create texture: %s\n", SDL_GetError()); + return 1; + } + if (dlg_menu_sfe->w != old_menu_size.w || dlg_menu_sfe->h != old_menu_size.h) { + SDL_SetWindowSize(sdl_menu_win, dlg_menu_sfe->w, dlg_menu_sfe->h); + old_menu_size.w = dlg_menu_sfe->w; + old_menu_size.h = dlg_menu_sfe->h; + } + SDL_UpdateTexture(sdl_menu_texture, NULL, dlg_menu_sfe->pixels, dlg_menu_sfe->pitch); + SDL_RenderClear(sdl_menu_renderer); + SDL_RenderTexture(sdl_menu_renderer, sdl_menu_texture, NULL, NULL); + SDL_RenderPresent(sdl_menu_renderer); + + SDL_DestroyTexture(sdl_menu_texture); + SDL_ShowWindow(sdl_menu_win); + } + + if (dlg_menu->isEnableSound()) { + SoundData *sd = rousku.getSound(); + sound.setSound(sd); + } else { + sound.closeSound(); + } + + SDL_SetWindowAlwaysOnTop(sdl_window, dlg_menu->isAlwaysOnTop()); // FIXME on false seems to stay behind tint2, but otherwis still stays on top of normal windows, maybe because of UTILITY-window? + + SDL_Delay(delay); + } + + SDL_DestroyWindow(sdl_window); + SDL_Quit(); + TTF_Quit(); + + return 0; +} diff --git a/menu.png b/menu.png new file mode 100644 index 0000000..ff92c75 Binary files /dev/null and b/menu.png differ diff --git a/skin/Alppisusi.tsk b/skin/Alppisusi.tsk new file mode 100644 index 0000000..6ba4bb7 --- /dev/null +++ b/skin/Alppisusi.tsk @@ -0,0 +1,122 @@ +name=jump +img_name=hyppaa +count=4 +interval=200 +x=0 +y=-7 + +name=pee +img_name=pissaus +count=7 +interval=20 +x=0 +y=0 + +name=roll_left +img_name=pyoriivasemmalle +count=4 +interval=150 +x=-3 +y=0 + +name=roll_right +img_name=pyorii +count=4 +interval=150 +x=3 +y=0 + +name=notice +img_name=hoksaa +count=4 +interval=100 +x=0 +y=0 + +name=tongue +img_name=kiali +count=4 +interval=100 +x=0 +y=0 + +name=crunch +img_name=rouskutus +count=4 +interval=200 +x=0 +y=0 + +name=bark +img_name=haukahdus +count=4 +interval=120 +x=0 +y=0 +sound=roh.wav +loop=1 + +name=jump_end +img_name=falling +count=4 +interval=200 +x=0 +y=9 + +name=left +img_name=laukka2 +count=6 +interval=200 +x=-1 +y=0 + +name=right +img_name=laukka +count=6 +interval=200 +x=1 +y=0 + +name=fast_left +img_name=laukka2 +count=6 +interval=50 +x=-5 +y=0 + +name=fast_right +img_name=laukka +count=6 +interval=50 +x=5 +y=0 + +name=drop +img_name=putoo +count=4 +interval=100 +x=0 +y=10 + +name=stay +img_name=paikka +count=4 +interval=200 +x=0 +y=0 + +name=flop +img_name=platsahtaa +count=4 +interval=100 +x=0 +y=0 +sound=tomsmaahan.wav +loop=0 + +name=hang +img_name=roikkuu +count=1 +interval=1000 +x=0 +y=0 diff --git a/skin/Alppisusi/falling/1.png b/skin/Alppisusi/falling/1.png new file mode 100644 index 0000000..1c45ae8 Binary files /dev/null and b/skin/Alppisusi/falling/1.png differ diff --git a/skin/Alppisusi/falling/2.png b/skin/Alppisusi/falling/2.png new file mode 100644 index 0000000..eaedf68 Binary files /dev/null and b/skin/Alppisusi/falling/2.png differ diff --git a/skin/Alppisusi/falling/3.png b/skin/Alppisusi/falling/3.png new file mode 100644 index 0000000..14c3b20 Binary files /dev/null and b/skin/Alppisusi/falling/3.png differ diff --git a/skin/Alppisusi/falling/4.png b/skin/Alppisusi/falling/4.png new file mode 100644 index 0000000..0daabb2 Binary files /dev/null and b/skin/Alppisusi/falling/4.png differ diff --git a/skin/Alppisusi/haukahdus/1.png b/skin/Alppisusi/haukahdus/1.png new file mode 100644 index 0000000..16d71c7 Binary files /dev/null and b/skin/Alppisusi/haukahdus/1.png differ diff --git a/skin/Alppisusi/haukahdus/2.png b/skin/Alppisusi/haukahdus/2.png new file mode 100644 index 0000000..a780377 Binary files /dev/null and b/skin/Alppisusi/haukahdus/2.png differ diff --git a/skin/Alppisusi/haukahdus/3.png b/skin/Alppisusi/haukahdus/3.png new file mode 100644 index 0000000..d8eabf0 Binary files /dev/null and b/skin/Alppisusi/haukahdus/3.png differ diff --git a/skin/Alppisusi/haukahdus/4.png b/skin/Alppisusi/haukahdus/4.png new file mode 100644 index 0000000..dc04552 Binary files /dev/null and b/skin/Alppisusi/haukahdus/4.png differ diff --git a/skin/Alppisusi/haukahdus/roh.wav b/skin/Alppisusi/haukahdus/roh.wav new file mode 100644 index 0000000..39cc192 Binary files /dev/null and b/skin/Alppisusi/haukahdus/roh.wav differ diff --git a/skin/Alppisusi/hoksaa/1.png b/skin/Alppisusi/hoksaa/1.png new file mode 100644 index 0000000..c7af676 Binary files /dev/null and b/skin/Alppisusi/hoksaa/1.png differ diff --git a/skin/Alppisusi/hoksaa/2.png b/skin/Alppisusi/hoksaa/2.png new file mode 100644 index 0000000..69bf4bb Binary files /dev/null and b/skin/Alppisusi/hoksaa/2.png differ diff --git a/skin/Alppisusi/hoksaa/3.png b/skin/Alppisusi/hoksaa/3.png new file mode 100644 index 0000000..3f7604d Binary files /dev/null and b/skin/Alppisusi/hoksaa/3.png differ diff --git a/skin/Alppisusi/hoksaa/4.png b/skin/Alppisusi/hoksaa/4.png new file mode 100644 index 0000000..94472fc Binary files /dev/null and b/skin/Alppisusi/hoksaa/4.png differ diff --git a/skin/Alppisusi/hyppaa/1.png b/skin/Alppisusi/hyppaa/1.png new file mode 100644 index 0000000..bf774c2 Binary files /dev/null and b/skin/Alppisusi/hyppaa/1.png differ diff --git a/skin/Alppisusi/hyppaa/2.png b/skin/Alppisusi/hyppaa/2.png new file mode 100644 index 0000000..81a6bcd Binary files /dev/null and b/skin/Alppisusi/hyppaa/2.png differ diff --git a/skin/Alppisusi/hyppaa/3.png b/skin/Alppisusi/hyppaa/3.png new file mode 100644 index 0000000..061d763 Binary files /dev/null and b/skin/Alppisusi/hyppaa/3.png differ diff --git a/skin/Alppisusi/hyppaa/4.png b/skin/Alppisusi/hyppaa/4.png new file mode 100644 index 0000000..81a6bcd Binary files /dev/null and b/skin/Alppisusi/hyppaa/4.png differ diff --git a/skin/Alppisusi/kiali/1.png b/skin/Alppisusi/kiali/1.png new file mode 100644 index 0000000..eda81b7 Binary files /dev/null and b/skin/Alppisusi/kiali/1.png differ diff --git a/skin/Alppisusi/kiali/2.png b/skin/Alppisusi/kiali/2.png new file mode 100644 index 0000000..93aeead Binary files /dev/null and b/skin/Alppisusi/kiali/2.png differ diff --git a/skin/Alppisusi/kiali/3.png b/skin/Alppisusi/kiali/3.png new file mode 100644 index 0000000..34b2c8b Binary files /dev/null and b/skin/Alppisusi/kiali/3.png differ diff --git a/skin/Alppisusi/kiali/4.png b/skin/Alppisusi/kiali/4.png new file mode 100644 index 0000000..a560305 Binary files /dev/null and b/skin/Alppisusi/kiali/4.png differ diff --git a/skin/Alppisusi/laukka/1.png b/skin/Alppisusi/laukka/1.png new file mode 100644 index 0000000..f40b207 Binary files /dev/null and b/skin/Alppisusi/laukka/1.png differ diff --git a/skin/Alppisusi/laukka/2.png b/skin/Alppisusi/laukka/2.png new file mode 100644 index 0000000..ad6d1f0 Binary files /dev/null and b/skin/Alppisusi/laukka/2.png differ diff --git a/skin/Alppisusi/laukka/3.png b/skin/Alppisusi/laukka/3.png new file mode 100644 index 0000000..4f0ff92 Binary files /dev/null and b/skin/Alppisusi/laukka/3.png differ diff --git a/skin/Alppisusi/laukka/4.png b/skin/Alppisusi/laukka/4.png new file mode 100644 index 0000000..422f4c5 Binary files /dev/null and b/skin/Alppisusi/laukka/4.png differ diff --git a/skin/Alppisusi/laukka/5.png b/skin/Alppisusi/laukka/5.png new file mode 100644 index 0000000..cf2b756 Binary files /dev/null and b/skin/Alppisusi/laukka/5.png differ diff --git a/skin/Alppisusi/laukka/6.png b/skin/Alppisusi/laukka/6.png new file mode 100644 index 0000000..c78cf43 Binary files /dev/null and b/skin/Alppisusi/laukka/6.png differ diff --git a/skin/Alppisusi/laukka2/1.png b/skin/Alppisusi/laukka2/1.png new file mode 100644 index 0000000..20b7a82 Binary files /dev/null and b/skin/Alppisusi/laukka2/1.png differ diff --git a/skin/Alppisusi/laukka2/2.png b/skin/Alppisusi/laukka2/2.png new file mode 100644 index 0000000..02dbdc6 Binary files /dev/null and b/skin/Alppisusi/laukka2/2.png differ diff --git a/skin/Alppisusi/laukka2/3.png b/skin/Alppisusi/laukka2/3.png new file mode 100644 index 0000000..ce30c2f Binary files /dev/null and b/skin/Alppisusi/laukka2/3.png differ diff --git a/skin/Alppisusi/laukka2/4.png b/skin/Alppisusi/laukka2/4.png new file mode 100644 index 0000000..af9b89b Binary files /dev/null and b/skin/Alppisusi/laukka2/4.png differ diff --git a/skin/Alppisusi/laukka2/5.png b/skin/Alppisusi/laukka2/5.png new file mode 100644 index 0000000..73d2646 Binary files /dev/null and b/skin/Alppisusi/laukka2/5.png differ diff --git a/skin/Alppisusi/laukka2/6.png b/skin/Alppisusi/laukka2/6.png new file mode 100644 index 0000000..0a56dda Binary files /dev/null and b/skin/Alppisusi/laukka2/6.png differ diff --git a/skin/Alppisusi/paikka/1.png b/skin/Alppisusi/paikka/1.png new file mode 100644 index 0000000..f05599b Binary files /dev/null and b/skin/Alppisusi/paikka/1.png differ diff --git a/skin/Alppisusi/paikka/2.png b/skin/Alppisusi/paikka/2.png new file mode 100644 index 0000000..f40b207 Binary files /dev/null and b/skin/Alppisusi/paikka/2.png differ diff --git a/skin/Alppisusi/paikka/3.png b/skin/Alppisusi/paikka/3.png new file mode 100644 index 0000000..f05599b Binary files /dev/null and b/skin/Alppisusi/paikka/3.png differ diff --git a/skin/Alppisusi/paikka/4.png b/skin/Alppisusi/paikka/4.png new file mode 100644 index 0000000..8f8ad82 Binary files /dev/null and b/skin/Alppisusi/paikka/4.png differ diff --git a/skin/Alppisusi/pissaus/1.png b/skin/Alppisusi/pissaus/1.png new file mode 100644 index 0000000..9525be6 Binary files /dev/null and b/skin/Alppisusi/pissaus/1.png differ diff --git a/skin/Alppisusi/pissaus/2.png b/skin/Alppisusi/pissaus/2.png new file mode 100644 index 0000000..5058933 Binary files /dev/null and b/skin/Alppisusi/pissaus/2.png differ diff --git a/skin/Alppisusi/pissaus/3.png b/skin/Alppisusi/pissaus/3.png new file mode 100644 index 0000000..56588d8 Binary files /dev/null and b/skin/Alppisusi/pissaus/3.png differ diff --git a/skin/Alppisusi/pissaus/4.png b/skin/Alppisusi/pissaus/4.png new file mode 100644 index 0000000..0f3b18b Binary files /dev/null and b/skin/Alppisusi/pissaus/4.png differ diff --git a/skin/Alppisusi/pissaus/5.png b/skin/Alppisusi/pissaus/5.png new file mode 100644 index 0000000..ea3c875 Binary files /dev/null and b/skin/Alppisusi/pissaus/5.png differ diff --git a/skin/Alppisusi/pissaus/6.png b/skin/Alppisusi/pissaus/6.png new file mode 100644 index 0000000..0f1f817 Binary files /dev/null and b/skin/Alppisusi/pissaus/6.png differ diff --git a/skin/Alppisusi/pissaus/7.png b/skin/Alppisusi/pissaus/7.png new file mode 100644 index 0000000..76dd74d Binary files /dev/null and b/skin/Alppisusi/pissaus/7.png differ diff --git a/skin/Alppisusi/platsahtaa/1.png b/skin/Alppisusi/platsahtaa/1.png new file mode 100644 index 0000000..d2d758a Binary files /dev/null and b/skin/Alppisusi/platsahtaa/1.png differ diff --git a/skin/Alppisusi/platsahtaa/2.png b/skin/Alppisusi/platsahtaa/2.png new file mode 100644 index 0000000..61706cf Binary files /dev/null and b/skin/Alppisusi/platsahtaa/2.png differ diff --git a/skin/Alppisusi/platsahtaa/3.png b/skin/Alppisusi/platsahtaa/3.png new file mode 100644 index 0000000..31975a2 Binary files /dev/null and b/skin/Alppisusi/platsahtaa/3.png differ diff --git a/skin/Alppisusi/platsahtaa/4.png b/skin/Alppisusi/platsahtaa/4.png new file mode 100644 index 0000000..ed0a34d Binary files /dev/null and b/skin/Alppisusi/platsahtaa/4.png differ diff --git a/skin/Alppisusi/platsahtaa/tomsmaahan.wav b/skin/Alppisusi/platsahtaa/tomsmaahan.wav new file mode 100644 index 0000000..584e7c4 Binary files /dev/null and b/skin/Alppisusi/platsahtaa/tomsmaahan.wav differ diff --git a/skin/Alppisusi/putoo/1.png b/skin/Alppisusi/putoo/1.png new file mode 100644 index 0000000..5651d32 Binary files /dev/null and b/skin/Alppisusi/putoo/1.png differ diff --git a/skin/Alppisusi/putoo/2.png b/skin/Alppisusi/putoo/2.png new file mode 100644 index 0000000..0f343f8 Binary files /dev/null and b/skin/Alppisusi/putoo/2.png differ diff --git a/skin/Alppisusi/putoo/3.png b/skin/Alppisusi/putoo/3.png new file mode 100644 index 0000000..3508154 Binary files /dev/null and b/skin/Alppisusi/putoo/3.png differ diff --git a/skin/Alppisusi/putoo/4.png b/skin/Alppisusi/putoo/4.png new file mode 100644 index 0000000..e1781b0 Binary files /dev/null and b/skin/Alppisusi/putoo/4.png differ diff --git a/skin/Alppisusi/pyorii/1.png b/skin/Alppisusi/pyorii/1.png new file mode 100644 index 0000000..ca908c4 Binary files /dev/null and b/skin/Alppisusi/pyorii/1.png differ diff --git a/skin/Alppisusi/pyorii/2.png b/skin/Alppisusi/pyorii/2.png new file mode 100644 index 0000000..25d27a2 Binary files /dev/null and b/skin/Alppisusi/pyorii/2.png differ diff --git a/skin/Alppisusi/pyorii/3.png b/skin/Alppisusi/pyorii/3.png new file mode 100644 index 0000000..f691c82 Binary files /dev/null and b/skin/Alppisusi/pyorii/3.png differ diff --git a/skin/Alppisusi/pyorii/4.png b/skin/Alppisusi/pyorii/4.png new file mode 100644 index 0000000..45007c1 Binary files /dev/null and b/skin/Alppisusi/pyorii/4.png differ diff --git a/skin/Alppisusi/pyoriivasemmalle/1.png b/skin/Alppisusi/pyoriivasemmalle/1.png new file mode 100644 index 0000000..4496c2e Binary files /dev/null and b/skin/Alppisusi/pyoriivasemmalle/1.png differ diff --git a/skin/Alppisusi/pyoriivasemmalle/2.png b/skin/Alppisusi/pyoriivasemmalle/2.png new file mode 100644 index 0000000..45007c1 Binary files /dev/null and b/skin/Alppisusi/pyoriivasemmalle/2.png differ diff --git a/skin/Alppisusi/pyoriivasemmalle/3.png b/skin/Alppisusi/pyoriivasemmalle/3.png new file mode 100644 index 0000000..dc038d7 Binary files /dev/null and b/skin/Alppisusi/pyoriivasemmalle/3.png differ diff --git a/skin/Alppisusi/pyoriivasemmalle/4.png b/skin/Alppisusi/pyoriivasemmalle/4.png new file mode 100644 index 0000000..25d27a2 Binary files /dev/null and b/skin/Alppisusi/pyoriivasemmalle/4.png differ diff --git a/skin/Alppisusi/roikkuu/1.png b/skin/Alppisusi/roikkuu/1.png new file mode 100644 index 0000000..bba8b69 Binary files /dev/null and b/skin/Alppisusi/roikkuu/1.png differ diff --git a/skin/Alppisusi/rouskutus/1.png b/skin/Alppisusi/rouskutus/1.png new file mode 100644 index 0000000..63bef78 Binary files /dev/null and b/skin/Alppisusi/rouskutus/1.png differ diff --git a/skin/Alppisusi/rouskutus/2.png b/skin/Alppisusi/rouskutus/2.png new file mode 100644 index 0000000..63bef78 Binary files /dev/null and b/skin/Alppisusi/rouskutus/2.png differ diff --git a/skin/Alppisusi/rouskutus/3.png b/skin/Alppisusi/rouskutus/3.png new file mode 100644 index 0000000..63bef78 Binary files /dev/null and b/skin/Alppisusi/rouskutus/3.png differ diff --git a/skin/Alppisusi/rouskutus/4.png b/skin/Alppisusi/rouskutus/4.png new file mode 100644 index 0000000..63bef78 Binary files /dev/null and b/skin/Alppisusi/rouskutus/4.png differ diff --git a/skin/Chibi.tsk b/skin/Chibi.tsk new file mode 100644 index 0000000..6ba4bb7 --- /dev/null +++ b/skin/Chibi.tsk @@ -0,0 +1,122 @@ +name=jump +img_name=hyppaa +count=4 +interval=200 +x=0 +y=-7 + +name=pee +img_name=pissaus +count=7 +interval=20 +x=0 +y=0 + +name=roll_left +img_name=pyoriivasemmalle +count=4 +interval=150 +x=-3 +y=0 + +name=roll_right +img_name=pyorii +count=4 +interval=150 +x=3 +y=0 + +name=notice +img_name=hoksaa +count=4 +interval=100 +x=0 +y=0 + +name=tongue +img_name=kiali +count=4 +interval=100 +x=0 +y=0 + +name=crunch +img_name=rouskutus +count=4 +interval=200 +x=0 +y=0 + +name=bark +img_name=haukahdus +count=4 +interval=120 +x=0 +y=0 +sound=roh.wav +loop=1 + +name=jump_end +img_name=falling +count=4 +interval=200 +x=0 +y=9 + +name=left +img_name=laukka2 +count=6 +interval=200 +x=-1 +y=0 + +name=right +img_name=laukka +count=6 +interval=200 +x=1 +y=0 + +name=fast_left +img_name=laukka2 +count=6 +interval=50 +x=-5 +y=0 + +name=fast_right +img_name=laukka +count=6 +interval=50 +x=5 +y=0 + +name=drop +img_name=putoo +count=4 +interval=100 +x=0 +y=10 + +name=stay +img_name=paikka +count=4 +interval=200 +x=0 +y=0 + +name=flop +img_name=platsahtaa +count=4 +interval=100 +x=0 +y=0 +sound=tomsmaahan.wav +loop=0 + +name=hang +img_name=roikkuu +count=1 +interval=1000 +x=0 +y=0 diff --git a/skin/Chibi/falling/1.png b/skin/Chibi/falling/1.png new file mode 100644 index 0000000..b8ec338 Binary files /dev/null and b/skin/Chibi/falling/1.png differ diff --git a/skin/Chibi/falling/2.png b/skin/Chibi/falling/2.png new file mode 100644 index 0000000..8bbc672 Binary files /dev/null and b/skin/Chibi/falling/2.png differ diff --git a/skin/Chibi/falling/3.png b/skin/Chibi/falling/3.png new file mode 100644 index 0000000..e781ab5 Binary files /dev/null and b/skin/Chibi/falling/3.png differ diff --git a/skin/Chibi/falling/4.png b/skin/Chibi/falling/4.png new file mode 100644 index 0000000..e81e258 Binary files /dev/null and b/skin/Chibi/falling/4.png differ diff --git a/skin/Chibi/haukahdus/1.png b/skin/Chibi/haukahdus/1.png new file mode 100644 index 0000000..78c73f2 Binary files /dev/null and b/skin/Chibi/haukahdus/1.png differ diff --git a/skin/Chibi/haukahdus/2.png b/skin/Chibi/haukahdus/2.png new file mode 100644 index 0000000..446108e Binary files /dev/null and b/skin/Chibi/haukahdus/2.png differ diff --git a/skin/Chibi/haukahdus/3.png b/skin/Chibi/haukahdus/3.png new file mode 100644 index 0000000..78c73f2 Binary files /dev/null and b/skin/Chibi/haukahdus/3.png differ diff --git a/skin/Chibi/haukahdus/4.png b/skin/Chibi/haukahdus/4.png new file mode 100644 index 0000000..fa439d1 Binary files /dev/null and b/skin/Chibi/haukahdus/4.png differ diff --git a/skin/Chibi/haukahdus/roh.wav b/skin/Chibi/haukahdus/roh.wav new file mode 100644 index 0000000..9e3a289 Binary files /dev/null and b/skin/Chibi/haukahdus/roh.wav differ diff --git a/skin/Chibi/hoksaa/1.png b/skin/Chibi/hoksaa/1.png new file mode 100644 index 0000000..d050992 Binary files /dev/null and b/skin/Chibi/hoksaa/1.png differ diff --git a/skin/Chibi/hoksaa/2.png b/skin/Chibi/hoksaa/2.png new file mode 100644 index 0000000..d050992 Binary files /dev/null and b/skin/Chibi/hoksaa/2.png differ diff --git a/skin/Chibi/hoksaa/3.png b/skin/Chibi/hoksaa/3.png new file mode 100644 index 0000000..fdc244a Binary files /dev/null and b/skin/Chibi/hoksaa/3.png differ diff --git a/skin/Chibi/hoksaa/4.png b/skin/Chibi/hoksaa/4.png new file mode 100644 index 0000000..fdc244a Binary files /dev/null and b/skin/Chibi/hoksaa/4.png differ diff --git a/skin/Chibi/hyppaa/1.png b/skin/Chibi/hyppaa/1.png new file mode 100644 index 0000000..917d50f Binary files /dev/null and b/skin/Chibi/hyppaa/1.png differ diff --git a/skin/Chibi/hyppaa/2.png b/skin/Chibi/hyppaa/2.png new file mode 100644 index 0000000..4149fc1 Binary files /dev/null and b/skin/Chibi/hyppaa/2.png differ diff --git a/skin/Chibi/hyppaa/3.png b/skin/Chibi/hyppaa/3.png new file mode 100644 index 0000000..e4a1856 Binary files /dev/null and b/skin/Chibi/hyppaa/3.png differ diff --git a/skin/Chibi/hyppaa/4.png b/skin/Chibi/hyppaa/4.png new file mode 100644 index 0000000..4ccc6c2 Binary files /dev/null and b/skin/Chibi/hyppaa/4.png differ diff --git a/skin/Chibi/kiali/1.png b/skin/Chibi/kiali/1.png new file mode 100644 index 0000000..70d32d9 Binary files /dev/null and b/skin/Chibi/kiali/1.png differ diff --git a/skin/Chibi/kiali/2.png b/skin/Chibi/kiali/2.png new file mode 100644 index 0000000..42e9072 Binary files /dev/null and b/skin/Chibi/kiali/2.png differ diff --git a/skin/Chibi/kiali/3.png b/skin/Chibi/kiali/3.png new file mode 100644 index 0000000..70d32d9 Binary files /dev/null and b/skin/Chibi/kiali/3.png differ diff --git a/skin/Chibi/kiali/4.png b/skin/Chibi/kiali/4.png new file mode 100644 index 0000000..08f7c3f Binary files /dev/null and b/skin/Chibi/kiali/4.png differ diff --git a/skin/Chibi/laukka/1.png b/skin/Chibi/laukka/1.png new file mode 100644 index 0000000..6c4ad2b Binary files /dev/null and b/skin/Chibi/laukka/1.png differ diff --git a/skin/Chibi/laukka/2.png b/skin/Chibi/laukka/2.png new file mode 100644 index 0000000..823dbaa Binary files /dev/null and b/skin/Chibi/laukka/2.png differ diff --git a/skin/Chibi/laukka/3.png b/skin/Chibi/laukka/3.png new file mode 100644 index 0000000..fd1d4e6 Binary files /dev/null and b/skin/Chibi/laukka/3.png differ diff --git a/skin/Chibi/laukka/4.png b/skin/Chibi/laukka/4.png new file mode 100644 index 0000000..252db11 Binary files /dev/null and b/skin/Chibi/laukka/4.png differ diff --git a/skin/Chibi/laukka/5.png b/skin/Chibi/laukka/5.png new file mode 100644 index 0000000..03d3d0e Binary files /dev/null and b/skin/Chibi/laukka/5.png differ diff --git a/skin/Chibi/laukka/6.png b/skin/Chibi/laukka/6.png new file mode 100644 index 0000000..585d2d9 Binary files /dev/null and b/skin/Chibi/laukka/6.png differ diff --git a/skin/Chibi/laukka2/1.png b/skin/Chibi/laukka2/1.png new file mode 100644 index 0000000..70d32d9 Binary files /dev/null and b/skin/Chibi/laukka2/1.png differ diff --git a/skin/Chibi/laukka2/2.png b/skin/Chibi/laukka2/2.png new file mode 100644 index 0000000..ce567be Binary files /dev/null and b/skin/Chibi/laukka2/2.png differ diff --git a/skin/Chibi/laukka2/3.png b/skin/Chibi/laukka2/3.png new file mode 100644 index 0000000..3957ec1 Binary files /dev/null and b/skin/Chibi/laukka2/3.png differ diff --git a/skin/Chibi/laukka2/4.png b/skin/Chibi/laukka2/4.png new file mode 100644 index 0000000..a760695 Binary files /dev/null and b/skin/Chibi/laukka2/4.png differ diff --git a/skin/Chibi/laukka2/5.png b/skin/Chibi/laukka2/5.png new file mode 100644 index 0000000..9cb3328 Binary files /dev/null and b/skin/Chibi/laukka2/5.png differ diff --git a/skin/Chibi/laukka2/6.png b/skin/Chibi/laukka2/6.png new file mode 100644 index 0000000..482b967 Binary files /dev/null and b/skin/Chibi/laukka2/6.png differ diff --git a/skin/Chibi/paikka/1.png b/skin/Chibi/paikka/1.png new file mode 100644 index 0000000..dcc0441 Binary files /dev/null and b/skin/Chibi/paikka/1.png differ diff --git a/skin/Chibi/paikka/2.png b/skin/Chibi/paikka/2.png new file mode 100644 index 0000000..31eca28 Binary files /dev/null and b/skin/Chibi/paikka/2.png differ diff --git a/skin/Chibi/paikka/3.png b/skin/Chibi/paikka/3.png new file mode 100644 index 0000000..33f4a12 Binary files /dev/null and b/skin/Chibi/paikka/3.png differ diff --git a/skin/Chibi/paikka/4.png b/skin/Chibi/paikka/4.png new file mode 100644 index 0000000..8f7cc85 Binary files /dev/null and b/skin/Chibi/paikka/4.png differ diff --git a/skin/Chibi/pissaus/1.png b/skin/Chibi/pissaus/1.png new file mode 100644 index 0000000..0dff021 Binary files /dev/null and b/skin/Chibi/pissaus/1.png differ diff --git a/skin/Chibi/pissaus/2.png b/skin/Chibi/pissaus/2.png new file mode 100644 index 0000000..327f262 Binary files /dev/null and b/skin/Chibi/pissaus/2.png differ diff --git a/skin/Chibi/pissaus/3.png b/skin/Chibi/pissaus/3.png new file mode 100644 index 0000000..e2f1832 Binary files /dev/null and b/skin/Chibi/pissaus/3.png differ diff --git a/skin/Chibi/pissaus/4.png b/skin/Chibi/pissaus/4.png new file mode 100644 index 0000000..9c63f7e Binary files /dev/null and b/skin/Chibi/pissaus/4.png differ diff --git a/skin/Chibi/pissaus/5.png b/skin/Chibi/pissaus/5.png new file mode 100644 index 0000000..51762c5 Binary files /dev/null and b/skin/Chibi/pissaus/5.png differ diff --git a/skin/Chibi/pissaus/6.png b/skin/Chibi/pissaus/6.png new file mode 100644 index 0000000..327f262 Binary files /dev/null and b/skin/Chibi/pissaus/6.png differ diff --git a/skin/Chibi/pissaus/7.png b/skin/Chibi/pissaus/7.png new file mode 100644 index 0000000..01aea62 Binary files /dev/null and b/skin/Chibi/pissaus/7.png differ diff --git a/skin/Chibi/platsahtaa/1.png b/skin/Chibi/platsahtaa/1.png new file mode 100644 index 0000000..8af6293 Binary files /dev/null and b/skin/Chibi/platsahtaa/1.png differ diff --git a/skin/Chibi/platsahtaa/2.png b/skin/Chibi/platsahtaa/2.png new file mode 100644 index 0000000..2c18697 Binary files /dev/null and b/skin/Chibi/platsahtaa/2.png differ diff --git a/skin/Chibi/platsahtaa/3.png b/skin/Chibi/platsahtaa/3.png new file mode 100644 index 0000000..393aeb5 Binary files /dev/null and b/skin/Chibi/platsahtaa/3.png differ diff --git a/skin/Chibi/platsahtaa/4.png b/skin/Chibi/platsahtaa/4.png new file mode 100644 index 0000000..5cb5a4a Binary files /dev/null and b/skin/Chibi/platsahtaa/4.png differ diff --git a/skin/Chibi/platsahtaa/tomsmaahan.wav b/skin/Chibi/platsahtaa/tomsmaahan.wav new file mode 100644 index 0000000..07cb603 Binary files /dev/null and b/skin/Chibi/platsahtaa/tomsmaahan.wav differ diff --git a/skin/Chibi/putoo/1.png b/skin/Chibi/putoo/1.png new file mode 100644 index 0000000..2fe0b94 Binary files /dev/null and b/skin/Chibi/putoo/1.png differ diff --git a/skin/Chibi/putoo/2.png b/skin/Chibi/putoo/2.png new file mode 100644 index 0000000..32cfc5d Binary files /dev/null and b/skin/Chibi/putoo/2.png differ diff --git a/skin/Chibi/putoo/3.png b/skin/Chibi/putoo/3.png new file mode 100644 index 0000000..2ab24ea Binary files /dev/null and b/skin/Chibi/putoo/3.png differ diff --git a/skin/Chibi/putoo/4.png b/skin/Chibi/putoo/4.png new file mode 100644 index 0000000..bd25487 Binary files /dev/null and b/skin/Chibi/putoo/4.png differ diff --git a/skin/Chibi/pyorii/1.png b/skin/Chibi/pyorii/1.png new file mode 100644 index 0000000..1208ffb Binary files /dev/null and b/skin/Chibi/pyorii/1.png differ diff --git a/skin/Chibi/pyorii/2.png b/skin/Chibi/pyorii/2.png new file mode 100644 index 0000000..cd84467 Binary files /dev/null and b/skin/Chibi/pyorii/2.png differ diff --git a/skin/Chibi/pyorii/3.png b/skin/Chibi/pyorii/3.png new file mode 100644 index 0000000..c54b3f5 Binary files /dev/null and b/skin/Chibi/pyorii/3.png differ diff --git a/skin/Chibi/pyorii/4.png b/skin/Chibi/pyorii/4.png new file mode 100644 index 0000000..e547af5 Binary files /dev/null and b/skin/Chibi/pyorii/4.png differ diff --git a/skin/Chibi/pyoriivasemmalle/1.png b/skin/Chibi/pyoriivasemmalle/1.png new file mode 100644 index 0000000..328a4f3 Binary files /dev/null and b/skin/Chibi/pyoriivasemmalle/1.png differ diff --git a/skin/Chibi/pyoriivasemmalle/2.png b/skin/Chibi/pyoriivasemmalle/2.png new file mode 100644 index 0000000..e547af5 Binary files /dev/null and b/skin/Chibi/pyoriivasemmalle/2.png differ diff --git a/skin/Chibi/pyoriivasemmalle/3.png b/skin/Chibi/pyoriivasemmalle/3.png new file mode 100644 index 0000000..03aea64 Binary files /dev/null and b/skin/Chibi/pyoriivasemmalle/3.png differ diff --git a/skin/Chibi/pyoriivasemmalle/4.png b/skin/Chibi/pyoriivasemmalle/4.png new file mode 100644 index 0000000..cd84467 Binary files /dev/null and b/skin/Chibi/pyoriivasemmalle/4.png differ diff --git a/skin/Chibi/roikkuu/1.png b/skin/Chibi/roikkuu/1.png new file mode 100644 index 0000000..2bf1ed2 Binary files /dev/null and b/skin/Chibi/roikkuu/1.png differ diff --git a/skin/Chibi/rouskutus/1.png b/skin/Chibi/rouskutus/1.png new file mode 100644 index 0000000..0cc5e12 Binary files /dev/null and b/skin/Chibi/rouskutus/1.png differ diff --git a/skin/Chibi/rouskutus/2.png b/skin/Chibi/rouskutus/2.png new file mode 100644 index 0000000..368b4b9 Binary files /dev/null and b/skin/Chibi/rouskutus/2.png differ diff --git a/skin/Chibi/rouskutus/3.png b/skin/Chibi/rouskutus/3.png new file mode 100644 index 0000000..0cc5e12 Binary files /dev/null and b/skin/Chibi/rouskutus/3.png differ diff --git a/skin/Chibi/rouskutus/4.png b/skin/Chibi/rouskutus/4.png new file mode 100644 index 0000000..1ad6b13 Binary files /dev/null and b/skin/Chibi/rouskutus/4.png differ diff --git a/skin/Tavallinen.tsk b/skin/Tavallinen.tsk new file mode 100644 index 0000000..78a850f --- /dev/null +++ b/skin/Tavallinen.tsk @@ -0,0 +1,122 @@ +name=jump +img_name=hyppaa +count=4 +interval=200 +x=0 +y=-7 + +name=pee +img_name=pissaus +count=7 +interval=20 +x=0 +y=0 + +name=roll_left +img_name=pyoriivasemmalle +count=4 +interval=150 +x=-3 +y=0 + +name=roll_right +img_name=pyorii +count=4 +interval=150 +x=3 +y=0 + +name=notice +img_name=hoksaa +count=4 +interval=100 +x=0 +y=0 + +name=tongue +img_name=kiali +count=4 +interval=100 +x=0 +y=0 + +name=crunch +img_name=rouskutus +count=4 +interval=200 +x=0 +y=0 + +name=bark +img_name=haukahdus +count=4 +interval=120 +x=0 +y=0 +sound=roh2.wav +loop=1 + +name=jump_end +img_name=falling +count=4 +interval=200 +x=0 +y=9 + +name=left +img_name=laukka2 +count=6 +interval=200 +x=-1 +y=0 + +name=right +img_name=laukka +count=6 +interval=200 +x=1 +y=0 + +name=fast_left +img_name=laukka2 +count=6 +interval=50 +x=-5 +y=0 + +name=fast_right +img_name=laukka +count=6 +interval=50 +x=5 +y=0 + +name=drop +img_name=putoo +count=4 +interval=100 +x=0 +y=10 + +name=stay +img_name=paikka +count=4 +interval=200 +x=0 +y=0 + +name=flop +img_name=platsahtaa +count=4 +interval=100 +x=0 +y=0 +sound=tomsmaahan.wav +loop=0 + +name=hang +img_name=roikkuu +count=1 +interval=1000 +x=0 +y=0 diff --git a/skin/Tavallinen/falling/1.png b/skin/Tavallinen/falling/1.png new file mode 100644 index 0000000..be8e455 Binary files /dev/null and b/skin/Tavallinen/falling/1.png differ diff --git a/skin/Tavallinen/falling/2.png b/skin/Tavallinen/falling/2.png new file mode 100644 index 0000000..7a5c9aa Binary files /dev/null and b/skin/Tavallinen/falling/2.png differ diff --git a/skin/Tavallinen/falling/3.png b/skin/Tavallinen/falling/3.png new file mode 100644 index 0000000..aec0c7e Binary files /dev/null and b/skin/Tavallinen/falling/3.png differ diff --git a/skin/Tavallinen/falling/4.png b/skin/Tavallinen/falling/4.png new file mode 100644 index 0000000..6a3aa85 Binary files /dev/null and b/skin/Tavallinen/falling/4.png differ diff --git a/skin/Tavallinen/haukahdus/1.png b/skin/Tavallinen/haukahdus/1.png new file mode 100644 index 0000000..013c150 Binary files /dev/null and b/skin/Tavallinen/haukahdus/1.png differ diff --git a/skin/Tavallinen/haukahdus/2.png b/skin/Tavallinen/haukahdus/2.png new file mode 100644 index 0000000..2d95fa0 Binary files /dev/null and b/skin/Tavallinen/haukahdus/2.png differ diff --git a/skin/Tavallinen/haukahdus/3.png b/skin/Tavallinen/haukahdus/3.png new file mode 100644 index 0000000..32c08be Binary files /dev/null and b/skin/Tavallinen/haukahdus/3.png differ diff --git a/skin/Tavallinen/haukahdus/4.png b/skin/Tavallinen/haukahdus/4.png new file mode 100644 index 0000000..03bca40 Binary files /dev/null and b/skin/Tavallinen/haukahdus/4.png differ diff --git a/skin/Tavallinen/haukahdus/roh2.wav b/skin/Tavallinen/haukahdus/roh2.wav new file mode 100644 index 0000000..f6ad5a1 Binary files /dev/null and b/skin/Tavallinen/haukahdus/roh2.wav differ diff --git a/skin/Tavallinen/hoksaa/1.png b/skin/Tavallinen/hoksaa/1.png new file mode 100644 index 0000000..c8a5c9d Binary files /dev/null and b/skin/Tavallinen/hoksaa/1.png differ diff --git a/skin/Tavallinen/hoksaa/2.png b/skin/Tavallinen/hoksaa/2.png new file mode 100644 index 0000000..783448f Binary files /dev/null and b/skin/Tavallinen/hoksaa/2.png differ diff --git a/skin/Tavallinen/hoksaa/3.png b/skin/Tavallinen/hoksaa/3.png new file mode 100644 index 0000000..33b5946 Binary files /dev/null and b/skin/Tavallinen/hoksaa/3.png differ diff --git a/skin/Tavallinen/hoksaa/4.png b/skin/Tavallinen/hoksaa/4.png new file mode 100644 index 0000000..db28ab2 Binary files /dev/null and b/skin/Tavallinen/hoksaa/4.png differ diff --git a/skin/Tavallinen/hyppaa/1.png b/skin/Tavallinen/hyppaa/1.png new file mode 100644 index 0000000..a2a647c Binary files /dev/null and b/skin/Tavallinen/hyppaa/1.png differ diff --git a/skin/Tavallinen/hyppaa/2.png b/skin/Tavallinen/hyppaa/2.png new file mode 100644 index 0000000..4bf9d71 Binary files /dev/null and b/skin/Tavallinen/hyppaa/2.png differ diff --git a/skin/Tavallinen/hyppaa/3.png b/skin/Tavallinen/hyppaa/3.png new file mode 100644 index 0000000..87af0fd Binary files /dev/null and b/skin/Tavallinen/hyppaa/3.png differ diff --git a/skin/Tavallinen/hyppaa/4.png b/skin/Tavallinen/hyppaa/4.png new file mode 100644 index 0000000..4bf9d71 Binary files /dev/null and b/skin/Tavallinen/hyppaa/4.png differ diff --git a/skin/Tavallinen/kiali/1.png b/skin/Tavallinen/kiali/1.png new file mode 100644 index 0000000..07c6b20 Binary files /dev/null and b/skin/Tavallinen/kiali/1.png differ diff --git a/skin/Tavallinen/kiali/2.png b/skin/Tavallinen/kiali/2.png new file mode 100644 index 0000000..ec8701c Binary files /dev/null and b/skin/Tavallinen/kiali/2.png differ diff --git a/skin/Tavallinen/kiali/3.png b/skin/Tavallinen/kiali/3.png new file mode 100644 index 0000000..f25baba Binary files /dev/null and b/skin/Tavallinen/kiali/3.png differ diff --git a/skin/Tavallinen/kiali/4.png b/skin/Tavallinen/kiali/4.png new file mode 100644 index 0000000..47197c0 Binary files /dev/null and b/skin/Tavallinen/kiali/4.png differ diff --git a/skin/Tavallinen/laukka/1.png b/skin/Tavallinen/laukka/1.png new file mode 100644 index 0000000..5c9e435 Binary files /dev/null and b/skin/Tavallinen/laukka/1.png differ diff --git a/skin/Tavallinen/laukka/2.png b/skin/Tavallinen/laukka/2.png new file mode 100644 index 0000000..026231a Binary files /dev/null and b/skin/Tavallinen/laukka/2.png differ diff --git a/skin/Tavallinen/laukka/3.png b/skin/Tavallinen/laukka/3.png new file mode 100644 index 0000000..20d4208 Binary files /dev/null and b/skin/Tavallinen/laukka/3.png differ diff --git a/skin/Tavallinen/laukka/4.png b/skin/Tavallinen/laukka/4.png new file mode 100644 index 0000000..c71cb5b Binary files /dev/null and b/skin/Tavallinen/laukka/4.png differ diff --git a/skin/Tavallinen/laukka/5.png b/skin/Tavallinen/laukka/5.png new file mode 100644 index 0000000..491f029 Binary files /dev/null and b/skin/Tavallinen/laukka/5.png differ diff --git a/skin/Tavallinen/laukka/6.png b/skin/Tavallinen/laukka/6.png new file mode 100644 index 0000000..fabfc86 Binary files /dev/null and b/skin/Tavallinen/laukka/6.png differ diff --git a/skin/Tavallinen/laukka2/1.png b/skin/Tavallinen/laukka2/1.png new file mode 100644 index 0000000..cb5f7c8 Binary files /dev/null and b/skin/Tavallinen/laukka2/1.png differ diff --git a/skin/Tavallinen/laukka2/2.png b/skin/Tavallinen/laukka2/2.png new file mode 100644 index 0000000..80dff3b Binary files /dev/null and b/skin/Tavallinen/laukka2/2.png differ diff --git a/skin/Tavallinen/laukka2/3.png b/skin/Tavallinen/laukka2/3.png new file mode 100644 index 0000000..20e7f7b Binary files /dev/null and b/skin/Tavallinen/laukka2/3.png differ diff --git a/skin/Tavallinen/laukka2/4.png b/skin/Tavallinen/laukka2/4.png new file mode 100644 index 0000000..c8d4873 Binary files /dev/null and b/skin/Tavallinen/laukka2/4.png differ diff --git a/skin/Tavallinen/laukka2/5.png b/skin/Tavallinen/laukka2/5.png new file mode 100644 index 0000000..663f5a0 Binary files /dev/null and b/skin/Tavallinen/laukka2/5.png differ diff --git a/skin/Tavallinen/laukka2/6.png b/skin/Tavallinen/laukka2/6.png new file mode 100644 index 0000000..e1587e1 Binary files /dev/null and b/skin/Tavallinen/laukka2/6.png differ diff --git a/skin/Tavallinen/paikka/1.png b/skin/Tavallinen/paikka/1.png new file mode 100644 index 0000000..0fe6b98 Binary files /dev/null and b/skin/Tavallinen/paikka/1.png differ diff --git a/skin/Tavallinen/paikka/2.png b/skin/Tavallinen/paikka/2.png new file mode 100644 index 0000000..e0350be Binary files /dev/null and b/skin/Tavallinen/paikka/2.png differ diff --git a/skin/Tavallinen/paikka/3.png b/skin/Tavallinen/paikka/3.png new file mode 100644 index 0000000..55b8e7b Binary files /dev/null and b/skin/Tavallinen/paikka/3.png differ diff --git a/skin/Tavallinen/paikka/4.png b/skin/Tavallinen/paikka/4.png new file mode 100644 index 0000000..44a24b5 Binary files /dev/null and b/skin/Tavallinen/paikka/4.png differ diff --git a/skin/Tavallinen/pissaus/1.png b/skin/Tavallinen/pissaus/1.png new file mode 100644 index 0000000..993795c Binary files /dev/null and b/skin/Tavallinen/pissaus/1.png differ diff --git a/skin/Tavallinen/pissaus/2.png b/skin/Tavallinen/pissaus/2.png new file mode 100644 index 0000000..f9d1475 Binary files /dev/null and b/skin/Tavallinen/pissaus/2.png differ diff --git a/skin/Tavallinen/pissaus/3.png b/skin/Tavallinen/pissaus/3.png new file mode 100644 index 0000000..e7ffdf4 Binary files /dev/null and b/skin/Tavallinen/pissaus/3.png differ diff --git a/skin/Tavallinen/pissaus/4.png b/skin/Tavallinen/pissaus/4.png new file mode 100644 index 0000000..157defd Binary files /dev/null and b/skin/Tavallinen/pissaus/4.png differ diff --git a/skin/Tavallinen/pissaus/5.png b/skin/Tavallinen/pissaus/5.png new file mode 100644 index 0000000..387586b Binary files /dev/null and b/skin/Tavallinen/pissaus/5.png differ diff --git a/skin/Tavallinen/pissaus/6.png b/skin/Tavallinen/pissaus/6.png new file mode 100644 index 0000000..5a7a5fa Binary files /dev/null and b/skin/Tavallinen/pissaus/6.png differ diff --git a/skin/Tavallinen/pissaus/7.png b/skin/Tavallinen/pissaus/7.png new file mode 100644 index 0000000..789b4e3 Binary files /dev/null and b/skin/Tavallinen/pissaus/7.png differ diff --git a/skin/Tavallinen/platsahtaa/1.png b/skin/Tavallinen/platsahtaa/1.png new file mode 100644 index 0000000..ad92937 Binary files /dev/null and b/skin/Tavallinen/platsahtaa/1.png differ diff --git a/skin/Tavallinen/platsahtaa/2.png b/skin/Tavallinen/platsahtaa/2.png new file mode 100644 index 0000000..a28d090 Binary files /dev/null and b/skin/Tavallinen/platsahtaa/2.png differ diff --git a/skin/Tavallinen/platsahtaa/3.png b/skin/Tavallinen/platsahtaa/3.png new file mode 100644 index 0000000..277ea80 Binary files /dev/null and b/skin/Tavallinen/platsahtaa/3.png differ diff --git a/skin/Tavallinen/platsahtaa/4.png b/skin/Tavallinen/platsahtaa/4.png new file mode 100644 index 0000000..1c38ed9 Binary files /dev/null and b/skin/Tavallinen/platsahtaa/4.png differ diff --git a/skin/Tavallinen/platsahtaa/tomsmaahan.wav b/skin/Tavallinen/platsahtaa/tomsmaahan.wav new file mode 100644 index 0000000..7d365e6 Binary files /dev/null and b/skin/Tavallinen/platsahtaa/tomsmaahan.wav differ diff --git a/skin/Tavallinen/putoo/1.png b/skin/Tavallinen/putoo/1.png new file mode 100644 index 0000000..ef4b54c Binary files /dev/null and b/skin/Tavallinen/putoo/1.png differ diff --git a/skin/Tavallinen/putoo/2.png b/skin/Tavallinen/putoo/2.png new file mode 100644 index 0000000..ba662b2 Binary files /dev/null and b/skin/Tavallinen/putoo/2.png differ diff --git a/skin/Tavallinen/putoo/3.png b/skin/Tavallinen/putoo/3.png new file mode 100644 index 0000000..4768aad Binary files /dev/null and b/skin/Tavallinen/putoo/3.png differ diff --git a/skin/Tavallinen/putoo/4.png b/skin/Tavallinen/putoo/4.png new file mode 100644 index 0000000..73cf1df Binary files /dev/null and b/skin/Tavallinen/putoo/4.png differ diff --git a/skin/Tavallinen/pyorii/1.png b/skin/Tavallinen/pyorii/1.png new file mode 100644 index 0000000..672f629 Binary files /dev/null and b/skin/Tavallinen/pyorii/1.png differ diff --git a/skin/Tavallinen/pyorii/2.png b/skin/Tavallinen/pyorii/2.png new file mode 100644 index 0000000..3399377 Binary files /dev/null and b/skin/Tavallinen/pyorii/2.png differ diff --git a/skin/Tavallinen/pyorii/3.png b/skin/Tavallinen/pyorii/3.png new file mode 100644 index 0000000..60e6c7b Binary files /dev/null and b/skin/Tavallinen/pyorii/3.png differ diff --git a/skin/Tavallinen/pyorii/4.png b/skin/Tavallinen/pyorii/4.png new file mode 100644 index 0000000..40e9f14 Binary files /dev/null and b/skin/Tavallinen/pyorii/4.png differ diff --git a/skin/Tavallinen/pyoriivasemmalle/1.png b/skin/Tavallinen/pyoriivasemmalle/1.png new file mode 100644 index 0000000..ae8cab9 Binary files /dev/null and b/skin/Tavallinen/pyoriivasemmalle/1.png differ diff --git a/skin/Tavallinen/pyoriivasemmalle/2.png b/skin/Tavallinen/pyoriivasemmalle/2.png new file mode 100644 index 0000000..afe5bd1 Binary files /dev/null and b/skin/Tavallinen/pyoriivasemmalle/2.png differ diff --git a/skin/Tavallinen/pyoriivasemmalle/3.png b/skin/Tavallinen/pyoriivasemmalle/3.png new file mode 100644 index 0000000..c4f0d2f Binary files /dev/null and b/skin/Tavallinen/pyoriivasemmalle/3.png differ diff --git a/skin/Tavallinen/pyoriivasemmalle/4.png b/skin/Tavallinen/pyoriivasemmalle/4.png new file mode 100644 index 0000000..783e1c4 Binary files /dev/null and b/skin/Tavallinen/pyoriivasemmalle/4.png differ diff --git a/skin/Tavallinen/roikkuu/1.png b/skin/Tavallinen/roikkuu/1.png new file mode 100644 index 0000000..7b22c54 Binary files /dev/null and b/skin/Tavallinen/roikkuu/1.png differ diff --git a/skin/Tavallinen/rouskutus/1.png b/skin/Tavallinen/rouskutus/1.png new file mode 100644 index 0000000..e64c133 Binary files /dev/null and b/skin/Tavallinen/rouskutus/1.png differ diff --git a/skin/Tavallinen/rouskutus/2.png b/skin/Tavallinen/rouskutus/2.png new file mode 100644 index 0000000..c2eff17 Binary files /dev/null and b/skin/Tavallinen/rouskutus/2.png differ diff --git a/skin/Tavallinen/rouskutus/3.png b/skin/Tavallinen/rouskutus/3.png new file mode 100644 index 0000000..147ef37 Binary files /dev/null and b/skin/Tavallinen/rouskutus/3.png differ diff --git a/skin/Tavallinen/rouskutus/4.png b/skin/Tavallinen/rouskutus/4.png new file mode 100644 index 0000000..3c6dfe9 Binary files /dev/null and b/skin/Tavallinen/rouskutus/4.png differ