View Single Post
Old 10-11-2021, 03:41 PM   #36
GerReader
Connoisseur
GerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of it
 
Posts: 52
Karma: 66200
Join Date: Oct 2020
Location: Germany, Rhein-Main
Device: PocketBook Touch HD 3
@Skeeve: How to implement automatic cell highlight switching

@Skeeve,

As mentioned in the main thread, here a sketch what needs to be done to implement your proposed improvement to the app. I assume you never contributed to the original SGT puzzle collection, so I need to explain some details how the API works.

a) You need to add a new control code for the event "short/long swap key changed", in "puzzles.h" at the enum from line 29 on, either after CURSOR_SELECT2, or after UI_UPPER_BOUND.

b) At line 564 in frontend/game.c you call "midend_process_key(me, 0, 0, UI_SWAPCHANGE, fe->swapped);" to pass the swap change event to the "midend" (which is the software layer between the frontend and the individual game, its purpose is to manage things like the undo/redo list and a lot of other service functions)

c) The midend will call "interpret_move" in the game file with this control code; in Solo this is at line 4009.
The interpret_move function will receive the raw input, either pixel coordinates when the game area was clicked, or control/button codes when a button was clicked. There you need to catch the swap change, and adjust the current highlight mode in the "game_ui *ui" struct.
After adjusting the highlight mode, return from interpret_move with the return value UI_UPDATE.

The function docs for interpret_move is found here:

https://www.chiark.greenend.org.uk/~...interpret-move

I would return with UI_UPDATE in your case, as the UI needs to be updated, but the switch between full / pencil mark highlight mode is not worth to be included in the undo/redo list.

For further information, the original SGT project development documentation is here:

https://www.chiark.greenend.org.uk/~...puzzles/devel/

Happy coding!
GerReader is offline   Reply With Quote