-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit, popup start screen done
- Loading branch information
0 parents
commit 572da2d
Showing
14 changed files
with
444 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: "FAP: Build for multiple SDK sources" | ||
# This will build your app for dev and release channels on GitHub. | ||
# It will also build your app every day to make sure it's up to date with the latest SDK changes. | ||
# See https://github.com/marketplace/actions/build-flipper-application-package-fap for more information | ||
|
||
on: | ||
push: | ||
## put your main branch name under "branches" | ||
#branches: | ||
# - master | ||
pull_request: | ||
schedule: | ||
# do a build every day | ||
- cron: "1 1 * * *" | ||
|
||
jobs: | ||
ufbt-build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
include: | ||
- name: dev channel | ||
sdk-channel: dev | ||
- name: release channel | ||
sdk-channel: release | ||
# You can add unofficial channels here. See ufbt action docs for more info. | ||
name: 'ufbt: Build for ${{ matrix.name }}' | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Build with ufbt | ||
uses: flipperdevices/flipperzero-ufbt-action@v0.1 | ||
id: build-app | ||
with: | ||
sdk-channel: ${{ matrix.sdk-channel }} | ||
- name: Upload app artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
# See ufbt action docs for other output variables | ||
name: ${{ github.event.repository.name }}-${{ steps.build-app.outputs.suffix }} | ||
path: ${{ steps.build-app.outputs.fap-artifacts }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Prerequisites | ||
*.d | ||
|
||
# Object files | ||
*.o | ||
*.ko | ||
*.obj | ||
*.elf | ||
|
||
# Linker output | ||
*.ilk | ||
*.map | ||
*.exp | ||
|
||
# Precompiled Headers | ||
*.gch | ||
*.pch | ||
|
||
# Libraries | ||
*.lib | ||
*.a | ||
*.la | ||
*.lo | ||
|
||
# Shared objects (inc. Windows DLLs) | ||
*.dll | ||
*.so | ||
*.so.* | ||
*.dylib | ||
|
||
# Executables | ||
*.exe | ||
*.out | ||
*.app | ||
*.i*86 | ||
*.x86_64 | ||
*.hex | ||
|
||
# Debug files | ||
*.dSYM/ | ||
*.su | ||
*.idb | ||
*.pdb | ||
|
||
# Kernel Module Compile Results | ||
*.mod* | ||
*.cmd | ||
.tmp_versions/ | ||
modules.order | ||
Module.symvers | ||
Mkfile.old | ||
dkms.conf | ||
|
||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# For details & more options, see documentation/AppManifests.md in firmware repo | ||
|
||
App( | ||
appid="minesweeper", # Must be unique | ||
name="Mine Sweeper", # Displayed in menus | ||
apptype=FlipperAppType.EXTERNAL, | ||
entry_point="minesweeper_app", | ||
stack_size=2 * 1024, | ||
fap_category="Games", | ||
|
||
# Optional values | ||
fap_version="0.1", | ||
fap_icon="minesweeper.png", # 10x10 1-bit PNG | ||
fap_description="Flipper Zero Minesweeper Implementation", | ||
fap_author="Alexander Rodriguez", | ||
# fap_weburl="https://github.com/user/minesweeper", | ||
fap_icon_assets="images", # Image assets to compile for this application | ||
) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include "minesweeper.h" | ||
|
||
typedef enum { | ||
None, | ||
} MineSweeperGameEvent; | ||
|
||
static void init_app_state(App* app) { | ||
memset(app->app_state, 0, sizeof(*app->app_state)); | ||
} | ||
|
||
void minesweeper_scenes_game_on_enter(void* context) { | ||
App* app = (App*)context; | ||
|
||
view_dispatcher_switch_to_view(app->view_dispatcher, MineSweeperLoadingView); | ||
|
||
init_app_state(app); | ||
|
||
app->empty_screen_view = empty_screen_get_view(app->empty_screen); | ||
|
||
view_dispatcher_switch_to_view(app->view_dispatcher, MineSweeperEmptyScreenView); | ||
} | ||
|
||
bool minesweeper_scenes_game_on_event(void* context, SceneManagerEvent event) { | ||
UNUSED(context); | ||
UNUSED(event); | ||
|
||
bool consumed = false; | ||
return consumed; | ||
} | ||
|
||
void minesweeper_scenes_game_on_exit(void* context) { | ||
UNUSED(context); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#ifndef GAME_SCREEN_H | ||
#define GAME_SCREEN_H | ||
|
||
void minesweeper_scenes_game_on_enter(void* context); | ||
bool minesweeper_scenes_game_on_event(void* context, SceneManagerEvent); | ||
void minesweeper_scenes_game_on_exit(void* context); | ||
|
||
#endif |
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
#include <furi.h> | ||
|
||
#include "minesweeper.h" | ||
#include "minesweeper_i.h" | ||
|
||
/* generated by fbt from .png files in images folder */ | ||
#include <minesweeper_icons.h> | ||
|
||
static void (*const minesweeper_scene_on_enter_handlers[])(void*) = { | ||
minesweeper_scenes_startup_scene_on_enter, | ||
minesweeper_scenes_game_on_enter, | ||
}; | ||
|
||
static bool (*const minesweeper_scene_on_event_handlers[])(void*, SceneManagerEvent) = { | ||
minesweeper_scenes_startup_scene_on_event, | ||
minesweeper_scenes_game_on_event, | ||
}; | ||
|
||
static void (*const minesweeper_scene_on_exit_handlers[])(void*) = { | ||
minesweeper_scenes_startup_scene_on_exit, | ||
minesweeper_scenes_game_on_exit, | ||
}; | ||
|
||
static const SceneManagerHandlers minesweeper_scene_manager_handlers = { | ||
.on_enter_handlers = minesweeper_scene_on_enter_handlers, | ||
.on_event_handlers = minesweeper_scene_on_event_handlers, | ||
.on_exit_handlers = minesweeper_scene_on_exit_handlers, | ||
.scene_num = MineSweeperSceneCount, | ||
}; | ||
|
||
static bool minesweeper_custom_callback(void* context, uint32_t custom_event) { | ||
furi_assert(context); | ||
App* app = context; | ||
return scene_manager_handle_custom_event(app->scene_manager, custom_event); | ||
} | ||
|
||
static bool minesweeper_back_event_callback(void* context) { | ||
furi_assert(context); | ||
App* app = context; | ||
return scene_manager_handle_back_event(app->scene_manager); | ||
} | ||
|
||
static App* app_alloc() { | ||
App* app = (App*)malloc(sizeof(App)); | ||
furi_assert(app); | ||
|
||
app->app_state = (AppState*)malloc(sizeof(AppState)); | ||
|
||
app->scene_manager = scene_manager_alloc(&minesweeper_scene_manager_handlers, app); | ||
furi_assert(app->scene_manager); | ||
|
||
app->view_dispatcher = view_dispatcher_alloc(); | ||
furi_assert(app->view_dispatcher); | ||
|
||
view_dispatcher_enable_queue(app->view_dispatcher); | ||
view_dispatcher_set_event_callback_context(app->view_dispatcher, app); | ||
view_dispatcher_set_custom_event_callback(app->view_dispatcher, minesweeper_custom_callback); | ||
view_dispatcher_set_navigation_event_callback(app->view_dispatcher, minesweeper_back_event_callback); | ||
|
||
app->popup_view = NULL; | ||
app->popup = popup_alloc(); | ||
view_dispatcher_add_view(app->view_dispatcher, MineSweeperPopupView, popup_get_view(app->popup)); | ||
|
||
app->empty_screen_view = NULL; | ||
app->empty_screen = empty_screen_alloc(); | ||
view_dispatcher_add_view(app->view_dispatcher, MineSweeperEmptyScreenView, empty_screen_get_view(app->empty_screen)); | ||
|
||
app->loading = loading_alloc(); | ||
view_dispatcher_add_view(app->view_dispatcher, MineSweeperLoadingView, loading_get_view(app->loading)); | ||
|
||
return app; | ||
|
||
} | ||
|
||
static void app_free(App* app) { | ||
furi_assert(app); | ||
|
||
for (MineSweeperView minesweeper_view = MineSweeperPopupView; minesweeper_view < MineSweeperPopupCount; minesweeper_view++) { | ||
view_dispatcher_remove_view(app->view_dispatcher, minesweeper_view); | ||
} | ||
|
||
scene_manager_free(app->scene_manager); | ||
|
||
view_dispatcher_free(app->view_dispatcher); | ||
|
||
popup_free(app->popup); | ||
empty_screen_free(app->empty_screen); | ||
loading_free(app->loading); | ||
|
||
free(app->app_state); | ||
free(app); | ||
|
||
} | ||
|
||
int32_t minesweeper_app(void* p) { | ||
UNUSED(p); | ||
|
||
App* app = app_alloc(); | ||
|
||
Gui* gui = furi_record_open(RECORD_GUI); | ||
|
||
view_dispatcher_attach_to_gui(app->view_dispatcher, gui, ViewDispatcherTypeFullscreen); | ||
|
||
scene_manager_next_scene(app->scene_manager, MineSweeperStartupScene); | ||
|
||
view_dispatcher_run(app->view_dispatcher); | ||
|
||
app_free(app); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
#ifndef MINESWEEPER_H | ||
#define MINESWEEPER_H | ||
|
||
#include <gui/view_dispatcher.h> | ||
#include <gui/scene_manager.h> | ||
#include <gui/modules/widget.h> | ||
#include <gui/modules/popup.h> | ||
#include <gui/modules/loading.h> | ||
#include <gui/modules/empty_screen.h> | ||
|
||
#include <string.h> // memset | ||
#include <unistd.h> // sleep | ||
|
||
#include "minesweeper_icons.h" | ||
//#include <gui/modules/text_input.h> | ||
//#include <gui/submenu.h> | ||
|
||
#define PLAY_WIDTH 16 | ||
#define PLAY_HEIGHT 7 | ||
#define TILE_WIDTH 8 | ||
|
||
#define MINE_COUNT 20 | ||
|
||
// Views | ||
typedef enum { | ||
MineSweeperPopupView, | ||
MineSweeperLoadingView, | ||
MineSweeperEmptyScreenView, | ||
MineSweeperPopupCount, // Leave at end | ||
} MineSweeperView; | ||
|
||
// Scenes | ||
typedef enum { | ||
MineSweeperStartupScene, | ||
MineSweeperGameScene, | ||
MineSweeperSceneCount, // Leave at end | ||
} MineSweeperScene; | ||
|
||
typedef enum { | ||
Tile0, | ||
Tile1, | ||
Tile2, | ||
Tile3, | ||
Tile4, | ||
Tile5, | ||
Tile6, | ||
Tile7, | ||
Tile8, | ||
TileClear, | ||
TileFlag, | ||
TileMine, | ||
} Tile; | ||
|
||
typedef enum { | ||
TileStatusEmpty, | ||
TileStatusMine, | ||
} TileStatus; | ||
|
||
typedef struct CurPos { | ||
uint8_t x; | ||
uint8_t y; | ||
} CurPos; | ||
|
||
// App state | ||
typedef struct AppState { | ||
TileStatus minefield[PLAY_HEIGHT][PLAY_WIDTH]; | ||
Tile playfield[PLAY_HEIGHT][PLAY_WIDTH]; | ||
//FuriTimer* timer; | ||
CurPos curPos; | ||
int fields_cleared; | ||
int flags_used; | ||
} AppState; | ||
|
||
// App | ||
typedef struct App { | ||
AppState* app_state; | ||
SceneManager* scene_manager; | ||
ViewDispatcher* view_dispatcher; | ||
View* popup_view; | ||
Popup* popup; | ||
View* empty_screen_view; | ||
EmptyScreen* empty_screen; | ||
Loading* loading; | ||
} App; | ||
|
||
|
||
#endif |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#ifndef MINESWEEPER_I_H | ||
#define MINESWEEPER_I_H | ||
|
||
#include "startup_screen.h" | ||
#include "game_screen.h" | ||
|
||
#endif |
Oops, something went wrong.