Update apps

This commit is contained in:
Willy-JL
2023-08-30 18:59:32 +02:00
parent 160ab755a2
commit ee37769ee2
308 changed files with 2314 additions and 801 deletions

21
applications/external/solitaire/LICENSE vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 Tibor Tálosi
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -5,7 +5,6 @@ App(
entry_point="solitaire_app",
requires=["gui", "storage", "canvas"],
stack_size=2 * 1024,
order=30,
fap_icon="solitaire_10px.png",
fap_category="Games",
fap_icon_assets="assets",

View File

@@ -44,6 +44,7 @@ typedef struct {
InputKey input;
bool started;
bool had_change;
bool processing;
bool longPress;
PlayState state;

View File

@@ -1,12 +1,15 @@
#include <stdlib.h>
#include <dolphin/dolphin.h>
#include <furi.h>
#include <gui/canvas_i.h>
#include "defines.h"
#include "common/ui.h"
#include "solitaire_icons.h"
#include <assets_icons.h>
#include <notification/notification.h>
#include <notification/notification_messages.h>
void init(GameState* game_state);
const NotificationSequence sequence_fail = {
&message_vibro_on,
&message_note_c4,
@@ -33,13 +36,6 @@ int8_t columns[7][3] = {
};
bool can_place_card(Card where, Card what) {
FURI_LOG_D(
APP_NAME,
"TESTING pip %i, letter %i with pip %i, letter %i",
where.pip,
where.character,
what.pip,
what.character);
bool a_black = where.pip == 0 || where.pip == 3;
bool b_black = what.pip == 0 || what.pip == 3;
if(a_black == b_black) return false;
@@ -53,86 +49,97 @@ bool can_place_card(Card where, Card what) {
}
static void draw_scene(Canvas* const canvas, const GameState* game_state) {
int deckIndex = game_state->deck.index;
if(game_state->dragging_deck) deckIndex--;
if(game_state->had_change) {
int deckIndex = game_state->deck.index;
if(game_state->dragging_deck) deckIndex--;
if((game_state->deck.index < (game_state->deck.card_count - 1) ||
game_state->deck.index == -1) &&
game_state->deck.card_count > 0) {
draw_card_back_at(columns[0][0], columns[0][1], canvas);
if(game_state->selectRow == 0 && game_state->selectColumn == 0) {
draw_rounded_box(
canvas,
columns[0][0] + 1,
columns[0][1] + 1,
CARD_WIDTH - 2,
CARD_HEIGHT - 2,
Inverse);
}
} else
draw_card_space(
columns[0][0],
columns[0][1],
game_state->selectRow == 0 && game_state->selectColumn == 0,
canvas);
//deck side
if(deckIndex >= 0) {
Card c = game_state->deck.cards[deckIndex];
draw_card_at_colored(
columns[1][0],
columns[1][1],
c.pip,
c.character,
game_state->selectRow == 0 && game_state->selectColumn == 1,
canvas);
} else
draw_card_space(
columns[1][0],
columns[1][1],
game_state->selectRow == 0 && game_state->selectColumn == 1,
canvas);
for(uint8_t i = 0; i < 4; i++) {
Card current = game_state->top_cards[i];
bool selected = game_state->selectRow == 0 && game_state->selectColumn == (i + 3);
if(current.disabled) {
draw_card_space(columns[i + 3][0], columns[i + 3][1], selected, canvas);
} else {
draw_card_at(
columns[i + 3][0], columns[i + 3][1], current.pip, current.character, canvas);
if(selected) {
if((game_state->deck.index < (game_state->deck.card_count - 1) ||
game_state->deck.index == -1) &&
game_state->deck.card_count > 0) {
draw_card_back_at(columns[0][0], columns[0][1], canvas);
if(game_state->selectRow == 0 && game_state->selectColumn == 0) {
draw_rounded_box(
canvas, columns[i + 3][0], columns[i + 3][1], CARD_WIDTH, CARD_HEIGHT, Inverse);
canvas,
columns[0][0] + 1,
columns[0][1] + 1,
CARD_WIDTH - 2,
CARD_HEIGHT - 2,
Inverse);
}
} else
draw_card_space(
columns[0][0],
columns[0][1],
game_state->selectRow == 0 && game_state->selectColumn == 0,
canvas);
//deck side
if(deckIndex >= 0) {
Card c = game_state->deck.cards[deckIndex];
draw_card_at_colored(
columns[1][0],
columns[1][1],
c.pip,
c.character,
game_state->selectRow == 0 && game_state->selectColumn == 1,
canvas);
} else
draw_card_space(
columns[1][0],
columns[1][1],
game_state->selectRow == 0 && game_state->selectColumn == 1,
canvas);
for(uint8_t i = 0; i < 4; i++) {
Card current = game_state->top_cards[i];
bool selected = game_state->selectRow == 0 && game_state->selectColumn == (i + 3);
if(current.disabled) {
draw_card_space(columns[i + 3][0], columns[i + 3][1], selected, canvas);
} else {
draw_card_at(
columns[i + 3][0], columns[i + 3][1], current.pip, current.character, canvas);
if(selected) {
draw_rounded_box(
canvas,
columns[i + 3][0],
columns[i + 3][1],
CARD_WIDTH,
CARD_HEIGHT,
Inverse);
}
}
}
}
for(uint8_t i = 0; i < 7; i++) {
bool selected = game_state->selectRow == 1 && game_state->selectColumn == i;
int8_t index = (game_state->bottom_columns[i].index - 1 - game_state->selected_card);
if(index < 0) index = 0;
draw_hand_column(
game_state->bottom_columns[i],
columns[i][0],
columns[i][2],
selected ? index : -1,
canvas);
}
for(uint8_t i = 0; i < 7; i++) {
bool selected = game_state->selectRow == 1 && game_state->selectColumn == i;
int8_t index = (game_state->bottom_columns[i].index - 1 - game_state->selected_card);
if(index < 0) index = 0;
draw_hand_column(
game_state->bottom_columns[i],
columns[i][0],
columns[i][2],
selected ? index : -1,
canvas);
}
int8_t pos[2] = {
columns[game_state->selectColumn][0],
columns[game_state->selectColumn][game_state->selectRow + 1]};
int8_t pos[2] = {
columns[game_state->selectColumn][0],
columns[game_state->selectColumn][game_state->selectRow + 1]};
/* draw_icon_clip(canvas, &I_card_graphics, pos[0] + CARD_HALF_WIDTH, pos[1] + CARD_HALF_HEIGHT, 30, 5, 5, 5,
Filled);*/
/* draw_icon_clip(canvas, &I_card_graphics, pos[0] + CARD_HALF_WIDTH, pos[1] + CARD_HALF_HEIGHT, 30, 5, 5, 5,
Filled);*/
if(game_state->dragging_hand.index > 0) {
draw_hand_column(
game_state->dragging_hand,
pos[0] + CARD_HALF_WIDTH + 3,
pos[1] + CARD_HALF_HEIGHT + 3,
-1,
canvas);
if(game_state->dragging_hand.index > 0) {
draw_hand_column(
game_state->dragging_hand,
pos[0] + CARD_HALF_WIDTH + 3,
pos[1] + CARD_HALF_HEIGHT + 3,
-1,
canvas);
}
clone_buffer(get_buffer(canvas), game_state->animation.buffer);
} else {
clone_buffer(game_state->animation.buffer, get_buffer(canvas));
}
}
@@ -154,9 +161,11 @@ static void draw_animation(Canvas* const canvas, const GameState* game_state) {
}
static void render_callback(Canvas* const canvas, void* ctx) {
furi_assert(ctx);
const GameState* game_state = ctx;
furi_mutex_acquire(game_state->mutex, FuriWaitForever);
furi_mutex_acquire(game_state->mutex, 25);
if(game_state == NULL) {
return;
}
switch(game_state->state) {
case GameStateAnimate:
@@ -253,7 +262,6 @@ bool place_on_top(Card* where, Card what) {
int8_t b_letter = (int8_t)what.character;
if(a_letter == 12) a_letter = -1;
if(b_letter == 12) b_letter = -1;
if(where->disabled && b_letter != -1) return false;
if((a_letter + 1) == b_letter) {
@@ -276,6 +284,9 @@ void tick(GameState* game_state, NotificationApp* notification) {
if(game_state->top_cards[0].character == 11 && game_state->top_cards[1].character == 11 &&
game_state->top_cards[2].character == 11 && game_state->top_cards[3].character == 11) {
game_state->state = GameStateAnimate;
game_state->had_change = true;
dolphin_deed(DolphinDeedPluginGameWin);
return;
}
}
@@ -406,6 +417,7 @@ void tick(GameState* game_state, NotificationApp* notification) {
}
void init(GameState* game_state) {
dolphin_deed(DolphinDeedPluginGameStart);
game_state->selectColumn = 0;
game_state->selected_card = 0;
game_state->selectRow = 0;
@@ -484,16 +496,17 @@ int32_t solitaire_app(void* p) {
FuriTimer* timer = furi_timer_alloc(update_timer_callback, FuriTimerTypePeriodic, event_queue);
furi_timer_start(timer, furi_kernel_get_tick_frequency() / 30);
Gui* gui = furi_record_open(RECORD_GUI);
Gui* gui = furi_record_open("gui");
gui_add_view_port(gui, view_port, GuiLayerFullscreen);
AppEvent event;
for(bool processing = true; processing;) {
FuriStatus event_status = furi_message_queue_get(event_queue, &event, 150);
furi_mutex_acquire(game_state->mutex, FuriWaitForever);
game_state->had_change = false;
if(event_status == FuriStatusOk) {
if(event.type == EventTypeKey) {
game_state->had_change = true;
if(event.input.type == InputTypeLong) {
game_state->longPress = true;
switch(event.input.key) {
@@ -540,6 +553,7 @@ int32_t solitaire_app(void* p) {
game_state->input = InputKeyMAX;
}
}
view_port_update(view_port);
furi_mutex_release(game_state->mutex);
}
@@ -561,5 +575,6 @@ free_and_exit:
free(game_state->deck.cards);
free(game_state);
furi_message_queue_free(event_queue);
return return_code;
}
}