8
8
#include <notification/notification.h>
9
9
#include <notification/notification_messages.h>
10
10
void init (GameState * game_state );
11
+
11
12
const NotificationSequence sequence_fail = {
12
13
& message_vibro_on ,
13
14
& message_note_c4 ,
@@ -47,62 +48,69 @@ bool can_place_card(Card where, Card what) {
47
48
}
48
49
49
50
static void draw_scene (Canvas * const canvas , const GameState * game_state ) {
50
- int deckIndex = game_state -> deck .index ;
51
- if (game_state -> dragging_deck )
52
- deckIndex -- ;
53
-
54
- if ((game_state -> deck .index < (game_state -> deck .card_count - 1 ) || game_state -> deck .index == -1 ) && game_state -> deck .card_count > 0 ) {
55
- draw_card_back_at (columns [0 ][0 ], columns [0 ][1 ], canvas );
56
- if (game_state -> selectRow == 0 && game_state -> selectColumn == 0 ) {
57
- draw_rounded_box (canvas , columns [0 ][0 ] + 1 , columns [0 ][1 ] + 1 , CARD_WIDTH - 2 , CARD_HEIGHT - 2 ,
58
- Inverse );
59
- }
60
- } else
61
- draw_card_space (columns [0 ][0 ], columns [0 ][1 ],
62
- game_state -> selectRow == 0 && game_state -> selectColumn == 0 ,
63
- canvas );
64
- //deck side
65
- if (deckIndex >= 0 ) {
66
- Card c = game_state -> deck .cards [deckIndex ];
67
- draw_card_at_colored (columns [1 ][0 ], columns [1 ][1 ], c .pip , c .character ,
68
- game_state -> selectRow == 0 && game_state -> selectColumn == 1 , canvas );
69
- } else
70
- draw_card_space (columns [1 ][0 ], columns [1 ][1 ],
71
- game_state -> selectRow == 0 && game_state -> selectColumn == 1 ,
72
- canvas );
73
51
74
- for ( uint8_t i = 0 ; i < 4 ; i ++ ) {
75
- Card current = game_state -> top_cards [ i ] ;
76
- bool selected = game_state -> selectRow == 0 && game_state -> selectColumn == ( i + 3 );
77
- if ( current . disabled ) {
78
- draw_card_space ( columns [ i + 3 ][ 0 ], columns [ i + 3 ][ 1 ], selected , canvas );
79
- } else {
80
- draw_card_at (columns [i + 3 ][0 ], columns [i + 3 ][1 ], current . pip , current . character , canvas );
81
- if (selected ) {
82
- draw_rounded_box (canvas , columns [i + 3 ][0 ], columns [i + 3 ][1 ], CARD_WIDTH , CARD_HEIGHT ,
52
+ if ( game_state -> had_change ) {
53
+ int deckIndex = game_state -> deck . index ;
54
+ if ( game_state -> dragging_deck )
55
+ deckIndex -- ;
56
+
57
+ if (( game_state -> deck . index < ( game_state -> deck . card_count - 1 ) || game_state -> deck . index == -1 ) && game_state -> deck . card_count > 0 ) {
58
+ draw_card_back_at (columns [0 ][0 ], columns [0 ][1 ], canvas );
59
+ if (game_state -> selectRow == 0 && game_state -> selectColumn == 0 ) {
60
+ draw_rounded_box (canvas , columns [0 ][0 ] + 1 , columns [0 ][1 ] + 1 , CARD_WIDTH - 2 , CARD_HEIGHT - 2 ,
83
61
Inverse );
84
62
}
63
+ } else
64
+ draw_card_space (columns [0 ][0 ], columns [0 ][1 ],
65
+ game_state -> selectRow == 0 && game_state -> selectColumn == 0 ,
66
+ canvas );
67
+ //deck side
68
+ if (deckIndex >= 0 ) {
69
+ Card c = game_state -> deck .cards [deckIndex ];
70
+ draw_card_at_colored (columns [1 ][0 ], columns [1 ][1 ], c .pip , c .character ,
71
+ game_state -> selectRow == 0 && game_state -> selectColumn == 1 , canvas );
72
+ } else
73
+ draw_card_space (columns [1 ][0 ], columns [1 ][1 ],
74
+ game_state -> selectRow == 0 && game_state -> selectColumn == 1 ,
75
+ canvas );
76
+
77
+ for (uint8_t i = 0 ; i < 4 ; i ++ ) {
78
+ Card current = game_state -> top_cards [i ];
79
+ bool selected = game_state -> selectRow == 0 && game_state -> selectColumn == (i + 3 );
80
+ if (current .disabled ) {
81
+ draw_card_space (columns [i + 3 ][0 ], columns [i + 3 ][1 ], selected , canvas );
82
+ } else {
83
+ draw_card_at (columns [i + 3 ][0 ], columns [i + 3 ][1 ], current .pip , current .character , canvas );
84
+ if (selected ) {
85
+ draw_rounded_box (canvas , columns [i + 3 ][0 ], columns [i + 3 ][1 ], CARD_WIDTH , CARD_HEIGHT ,
86
+ Inverse );
87
+ }
88
+ }
85
89
}
86
- }
87
90
88
- for (uint8_t i = 0 ; i < 7 ; i ++ ) {
89
- bool selected = game_state -> selectRow == 1 && game_state -> selectColumn == i ;
90
- int8_t index = (game_state -> bottom_columns [i ].index - 1 - game_state -> selected_card );
91
- if (index < 0 )index = 0 ;
92
- draw_hand_column (game_state -> bottom_columns [i ], columns [i ][0 ], columns [i ][2 ],
93
- selected ? index : -1 , canvas );
94
- }
91
+ for (uint8_t i = 0 ; i < 7 ; i ++ ) {
92
+ bool selected = game_state -> selectRow == 1 && game_state -> selectColumn == i ;
93
+ int8_t index = (game_state -> bottom_columns [i ].index - 1 - game_state -> selected_card );
94
+ if (index < 0 )index = 0 ;
95
+ draw_hand_column (game_state -> bottom_columns [i ], columns [i ][0 ], columns [i ][2 ],
96
+ selected ? index : -1 , canvas );
97
+ }
98
+
99
+ int8_t pos [2 ] = {columns [game_state -> selectColumn ][0 ],
100
+ columns [game_state -> selectColumn ][game_state -> selectRow + 1 ]};
95
101
96
- int8_t pos [2 ] = { columns [ game_state -> selectColumn ][ 0 ] ,
97
- columns [ game_state -> selectColumn ][ game_state -> selectRow + 1 ]};
102
+ /* draw_icon_clip(canvas, &I_card_graphics, pos[0] + CARD_HALF_WIDTH, pos[1] + CARD_HALF_HEIGHT, 30, 5, 5, 5 ,
103
+ Filled);*/
98
104
99
- /* draw_icon_clip(canvas, &I_card_graphics, pos[0] + CARD_HALF_WIDTH, pos[1] + CARD_HALF_HEIGHT, 30, 5, 5, 5,
100
- Filled);*/
105
+ if (game_state -> dragging_hand .index > 0 ) {
106
+ draw_hand_column (game_state -> dragging_hand ,
107
+ pos [0 ] + CARD_HALF_WIDTH + 3 , pos [1 ] + CARD_HALF_HEIGHT + 3 ,
108
+ -1 , canvas );
109
+ }
101
110
102
- if (game_state -> dragging_hand .index > 0 ) {
103
- draw_hand_column (game_state -> dragging_hand ,
104
- pos [0 ] + CARD_HALF_WIDTH + 3 , pos [1 ] + CARD_HALF_HEIGHT + 3 ,
105
- -1 , canvas );
111
+ clone_buffer (get_buffer (canvas ), game_state -> animation .buffer );
112
+ }else {
113
+ clone_buffer (game_state -> animation .buffer , get_buffer (canvas ));
106
114
}
107
115
}
108
116
@@ -247,6 +255,7 @@ void tick(GameState *game_state, NotificationApp *notification) {
247
255
if (game_state -> top_cards [0 ].character == 11 && game_state -> top_cards [1 ].character == 11 &&
248
256
game_state -> top_cards [2 ].character == 11 && game_state -> top_cards [3 ].character == 11 ) {
249
257
game_state -> state = GameStateAnimate ;
258
+ game_state -> had_change = true;
250
259
dolphin_deed (DolphinDeedPluginGameWin );
251
260
252
261
return ;
@@ -473,9 +482,10 @@ int32_t solitaire_app(void *p) {
473
482
for (bool processing = true; processing ;) {
474
483
FuriStatus event_status = furi_message_queue_get (event_queue , & event , 150 );
475
484
furi_mutex_acquire (game_state -> mutex , FuriWaitForever );
476
- bool hadChange = false;
485
+ game_state -> had_change = false;
477
486
if (event_status == FuriStatusOk ) {
478
487
if (event .type == EventTypeKey ) {
488
+ game_state -> had_change = true;
479
489
if (event .input .type == InputTypeLong ) {
480
490
game_state -> longPress = true;
481
491
switch (event .input .key ) {
@@ -505,7 +515,6 @@ int32_t solitaire_app(void *p) {
505
515
init (game_state );
506
516
}
507
517
else {
508
- hadChange = true;
509
518
game_state -> input = event .input .key ;
510
519
}
511
520
break ;
@@ -527,8 +536,8 @@ int32_t solitaire_app(void *p) {
527
536
FURI_LOG_W (APP_NAME , "osMessageQueue: event timeout" );
528
537
// event timeout
529
538
}
530
- if ( hadChange || game_state -> state == GameStateAnimate )
531
- view_port_update (view_port );
539
+
540
+ view_port_update (view_port );
532
541
furi_mutex_release (game_state -> mutex );
533
542
}
534
543
@@ -551,5 +560,6 @@ int32_t solitaire_app(void *p) {
551
560
free (game_state -> deck .cards );
552
561
free (game_state );
553
562
furi_message_queue_free (event_queue );
563
+
554
564
return return_code ;
555
565
}
0 commit comments