diff --git a/fonts/SmallFont/ɢ.png b/fonts/SmallFont/ɢ.png new file mode 100644 index 0000000..cc525f1 Binary files /dev/null and b/fonts/SmallFont/ɢ.png differ diff --git a/fonts/SmallFont/ᴜ.png b/fonts/SmallFont/ᴜ.png new file mode 100644 index 0000000..5e26d9d Binary files /dev/null and b/fonts/SmallFont/ᴜ.png differ diff --git a/fonts/SmallFont/♥.png b/fonts/SmallFont/♥.png new file mode 100644 index 0000000..4caaf63 Binary files /dev/null and b/fonts/SmallFont/♥.png differ diff --git a/fonts/SmallFont/、.png b/fonts/SmallFont/、.png new file mode 100644 index 0000000..60f3dc4 Binary files /dev/null and b/fonts/SmallFont/、.png differ diff --git a/fonts/SmallFont/。.png b/fonts/SmallFont/。.png new file mode 100644 index 0000000..7a3af9d Binary files /dev/null and b/fonts/SmallFont/。.png differ diff --git a/fonts/SmallFont/〜.png b/fonts/SmallFont/〜.png new file mode 100644 index 0000000..aa40fc2 Binary files /dev/null and b/fonts/SmallFont/〜.png differ diff --git a/fonts/SmallFont/え.png b/fonts/SmallFont/え.png new file mode 100644 index 0000000..e8c5955 Binary files /dev/null and b/fonts/SmallFont/え.png differ diff --git a/fonts/SmallFont/が.png b/fonts/SmallFont/が.png new file mode 100644 index 0000000..a90a517 Binary files /dev/null and b/fonts/SmallFont/が.png differ diff --git a/fonts/SmallFont/き.png b/fonts/SmallFont/き.png new file mode 100644 index 0000000..66e3d1b Binary files /dev/null and b/fonts/SmallFont/き.png differ diff --git a/fonts/SmallFont/じ.png b/fonts/SmallFont/じ.png new file mode 100644 index 0000000..b5a7772 Binary files /dev/null and b/fonts/SmallFont/じ.png differ diff --git a/fonts/SmallFont/ず.png b/fonts/SmallFont/ず.png new file mode 100644 index 0000000..d835382 Binary files /dev/null and b/fonts/SmallFont/ず.png differ diff --git a/fonts/SmallFont/せ.png b/fonts/SmallFont/せ.png new file mode 100644 index 0000000..3658c7e Binary files /dev/null and b/fonts/SmallFont/せ.png differ diff --git a/fonts/SmallFont/ぞ.png b/fonts/SmallFont/ぞ.png new file mode 100644 index 0000000..ddf7939 Binary files /dev/null and b/fonts/SmallFont/ぞ.png differ diff --git a/fonts/SmallFont/た.png b/fonts/SmallFont/た.png new file mode 100644 index 0000000..da6e4f3 Binary files /dev/null and b/fonts/SmallFont/た.png differ diff --git a/fonts/SmallFont/て.png b/fonts/SmallFont/て.png new file mode 100644 index 0000000..73e2b66 Binary files /dev/null and b/fonts/SmallFont/て.png differ diff --git a/fonts/SmallFont/ど.png b/fonts/SmallFont/ど.png new file mode 100644 index 0000000..0118cd5 Binary files /dev/null and b/fonts/SmallFont/ど.png differ diff --git a/fonts/SmallFont/な.png b/fonts/SmallFont/な.png new file mode 100644 index 0000000..7197f16 Binary files /dev/null and b/fonts/SmallFont/な.png differ diff --git a/fonts/SmallFont/に.png b/fonts/SmallFont/に.png new file mode 100644 index 0000000..e72cd71 Binary files /dev/null and b/fonts/SmallFont/に.png differ diff --git a/fonts/SmallFont/ぬ.png b/fonts/SmallFont/ぬ.png new file mode 100644 index 0000000..9aa66fd Binary files /dev/null and b/fonts/SmallFont/ぬ.png differ diff --git a/fonts/SmallFont/の.png b/fonts/SmallFont/の.png new file mode 100644 index 0000000..9fc64bf Binary files /dev/null and b/fonts/SmallFont/の.png differ diff --git a/fonts/SmallFont/は.png b/fonts/SmallFont/は.png new file mode 100644 index 0000000..ce1e2cb Binary files /dev/null and b/fonts/SmallFont/は.png differ diff --git a/fonts/SmallFont/ひ.png b/fonts/SmallFont/ひ.png new file mode 100644 index 0000000..51615c7 Binary files /dev/null and b/fonts/SmallFont/ひ.png differ diff --git a/fonts/SmallFont/へ.png b/fonts/SmallFont/へ.png new file mode 100644 index 0000000..ca8eef1 Binary files /dev/null and b/fonts/SmallFont/へ.png differ diff --git a/fonts/SmallFont/ほ.png b/fonts/SmallFont/ほ.png new file mode 100644 index 0000000..0fadbfc Binary files /dev/null and b/fonts/SmallFont/ほ.png differ diff --git a/fonts/SmallFont/む.png b/fonts/SmallFont/む.png new file mode 100644 index 0000000..7a93531 Binary files /dev/null and b/fonts/SmallFont/む.png differ diff --git a/fonts/SmallFont/も.png b/fonts/SmallFont/も.png new file mode 100644 index 0000000..064d441 Binary files /dev/null and b/fonts/SmallFont/も.png differ diff --git a/fonts/SmallFont/ら.png b/fonts/SmallFont/ら.png new file mode 100644 index 0000000..6689f0e Binary files /dev/null and b/fonts/SmallFont/ら.png differ diff --git a/fonts/SmallFont/り.png b/fonts/SmallFont/り.png new file mode 100644 index 0000000..1a93393 Binary files /dev/null and b/fonts/SmallFont/り.png differ diff --git a/fonts/SmallFont/る.png b/fonts/SmallFont/る.png new file mode 100644 index 0000000..bc7a530 Binary files /dev/null and b/fonts/SmallFont/る.png differ diff --git a/fonts/SmallFont/れ.png b/fonts/SmallFont/れ.png new file mode 100644 index 0000000..cbad6c2 Binary files /dev/null and b/fonts/SmallFont/れ.png differ diff --git a/fonts/SmallFont/を.png b/fonts/SmallFont/を.png new file mode 100644 index 0000000..1d4d271 Binary files /dev/null and b/fonts/SmallFont/を.png differ diff --git a/fonts/SmallFont/ァ.png b/fonts/SmallFont/ァ.png new file mode 100644 index 0000000..5216df7 Binary files /dev/null and b/fonts/SmallFont/ァ.png differ diff --git a/fonts/SmallFont/ア.png b/fonts/SmallFont/ア.png new file mode 100644 index 0000000..8442767 Binary files /dev/null and b/fonts/SmallFont/ア.png differ diff --git a/fonts/SmallFont/ィ.png b/fonts/SmallFont/ィ.png new file mode 100644 index 0000000..1170f1b Binary files /dev/null and b/fonts/SmallFont/ィ.png differ diff --git a/fonts/SmallFont/イ.png b/fonts/SmallFont/イ.png new file mode 100644 index 0000000..88c687b Binary files /dev/null and b/fonts/SmallFont/イ.png differ diff --git a/fonts/SmallFont/ゥ.png b/fonts/SmallFont/ゥ.png new file mode 100644 index 0000000..c81d865 Binary files /dev/null and b/fonts/SmallFont/ゥ.png differ diff --git a/fonts/SmallFont/ウ.png b/fonts/SmallFont/ウ.png new file mode 100644 index 0000000..2ae2527 Binary files /dev/null and b/fonts/SmallFont/ウ.png differ diff --git a/fonts/SmallFont/ェ.png b/fonts/SmallFont/ェ.png new file mode 100644 index 0000000..b3ce710 Binary files /dev/null and b/fonts/SmallFont/ェ.png differ diff --git a/fonts/SmallFont/エ.png b/fonts/SmallFont/エ.png new file mode 100644 index 0000000..dda5828 Binary files /dev/null and b/fonts/SmallFont/エ.png differ diff --git a/fonts/SmallFont/ォ.png b/fonts/SmallFont/ォ.png new file mode 100644 index 0000000..f88ca2b Binary files /dev/null and b/fonts/SmallFont/ォ.png differ diff --git a/fonts/SmallFont/オ.png b/fonts/SmallFont/オ.png new file mode 100644 index 0000000..b951d12 Binary files /dev/null and b/fonts/SmallFont/オ.png differ diff --git a/fonts/SmallFont/カ.png b/fonts/SmallFont/カ.png new file mode 100644 index 0000000..0d58ba1 Binary files /dev/null and b/fonts/SmallFont/カ.png differ diff --git a/fonts/SmallFont/キ.png b/fonts/SmallFont/キ.png new file mode 100644 index 0000000..71f84d2 Binary files /dev/null and b/fonts/SmallFont/キ.png differ diff --git a/fonts/SmallFont/ク.png b/fonts/SmallFont/ク.png new file mode 100644 index 0000000..b2cdc74 Binary files /dev/null and b/fonts/SmallFont/ク.png differ diff --git a/fonts/SmallFont/ケ.png b/fonts/SmallFont/ケ.png new file mode 100644 index 0000000..a3fc417 Binary files /dev/null and b/fonts/SmallFont/ケ.png differ diff --git a/fonts/SmallFont/コ.png b/fonts/SmallFont/コ.png new file mode 100644 index 0000000..a952374 Binary files /dev/null and b/fonts/SmallFont/コ.png differ diff --git a/fonts/SmallFont/サ.png b/fonts/SmallFont/サ.png new file mode 100644 index 0000000..d97e7fb Binary files /dev/null and b/fonts/SmallFont/サ.png differ diff --git a/fonts/SmallFont/シ.png b/fonts/SmallFont/シ.png new file mode 100644 index 0000000..8d18ce5 Binary files /dev/null and b/fonts/SmallFont/シ.png differ diff --git a/fonts/SmallFont/ス.png b/fonts/SmallFont/ス.png new file mode 100644 index 0000000..9109cad Binary files /dev/null and b/fonts/SmallFont/ス.png differ diff --git a/fonts/SmallFont/セ.png b/fonts/SmallFont/セ.png new file mode 100644 index 0000000..0f71d60 Binary files /dev/null and b/fonts/SmallFont/セ.png differ diff --git a/fonts/SmallFont/ソ.png b/fonts/SmallFont/ソ.png new file mode 100644 index 0000000..0e6998a Binary files /dev/null and b/fonts/SmallFont/ソ.png differ diff --git a/fonts/SmallFont/タ.png b/fonts/SmallFont/タ.png new file mode 100644 index 0000000..68c4ed2 Binary files /dev/null and b/fonts/SmallFont/タ.png differ diff --git a/fonts/SmallFont/チ.png b/fonts/SmallFont/チ.png new file mode 100644 index 0000000..ea96e0a Binary files /dev/null and b/fonts/SmallFont/チ.png differ diff --git a/fonts/SmallFont/ッ.png b/fonts/SmallFont/ッ.png new file mode 100644 index 0000000..7958adf Binary files /dev/null and b/fonts/SmallFont/ッ.png differ diff --git a/fonts/SmallFont/ツ.png b/fonts/SmallFont/ツ.png new file mode 100644 index 0000000..bae77c6 Binary files /dev/null and b/fonts/SmallFont/ツ.png differ diff --git a/fonts/SmallFont/テ.png b/fonts/SmallFont/テ.png new file mode 100644 index 0000000..4a56e8c Binary files /dev/null and b/fonts/SmallFont/テ.png differ diff --git a/fonts/SmallFont/ト.png b/fonts/SmallFont/ト.png new file mode 100644 index 0000000..1c6bfb4 Binary files /dev/null and b/fonts/SmallFont/ト.png differ diff --git a/fonts/SmallFont/ド.png b/fonts/SmallFont/ド.png new file mode 100644 index 0000000..1180bf6 Binary files /dev/null and b/fonts/SmallFont/ド.png differ diff --git a/fonts/SmallFont/ナ.png b/fonts/SmallFont/ナ.png new file mode 100644 index 0000000..d72c218 Binary files /dev/null and b/fonts/SmallFont/ナ.png differ diff --git a/fonts/SmallFont/ニ.png b/fonts/SmallFont/ニ.png new file mode 100644 index 0000000..23680ac Binary files /dev/null and b/fonts/SmallFont/ニ.png differ diff --git a/fonts/SmallFont/ヌ.png b/fonts/SmallFont/ヌ.png new file mode 100644 index 0000000..8cd8326 Binary files /dev/null and b/fonts/SmallFont/ヌ.png differ diff --git a/fonts/SmallFont/ネ.png b/fonts/SmallFont/ネ.png new file mode 100644 index 0000000..e07d0c2 Binary files /dev/null and b/fonts/SmallFont/ネ.png differ diff --git a/fonts/SmallFont/ノ.png b/fonts/SmallFont/ノ.png new file mode 100644 index 0000000..028026e Binary files /dev/null and b/fonts/SmallFont/ノ.png differ diff --git a/fonts/SmallFont/ハ.png b/fonts/SmallFont/ハ.png new file mode 100644 index 0000000..c40ce29 Binary files /dev/null and b/fonts/SmallFont/ハ.png differ diff --git a/fonts/SmallFont/ヒ.png b/fonts/SmallFont/ヒ.png new file mode 100644 index 0000000..5551e48 Binary files /dev/null and b/fonts/SmallFont/ヒ.png differ diff --git a/fonts/SmallFont/フ.png b/fonts/SmallFont/フ.png new file mode 100644 index 0000000..bcc90ba Binary files /dev/null and b/fonts/SmallFont/フ.png differ diff --git a/fonts/SmallFont/ヘ.png b/fonts/SmallFont/ヘ.png new file mode 100644 index 0000000..90a880e Binary files /dev/null and b/fonts/SmallFont/ヘ.png differ diff --git a/fonts/SmallFont/ホ.png b/fonts/SmallFont/ホ.png new file mode 100644 index 0000000..15de393 Binary files /dev/null and b/fonts/SmallFont/ホ.png differ diff --git a/fonts/SmallFont/マ.png b/fonts/SmallFont/マ.png new file mode 100644 index 0000000..22a8680 Binary files /dev/null and b/fonts/SmallFont/マ.png differ diff --git a/fonts/SmallFont/ミ.png b/fonts/SmallFont/ミ.png new file mode 100644 index 0000000..bdd1cbf Binary files /dev/null and b/fonts/SmallFont/ミ.png differ diff --git a/fonts/SmallFont/ム.png b/fonts/SmallFont/ム.png new file mode 100644 index 0000000..d0db321 Binary files /dev/null and b/fonts/SmallFont/ム.png differ diff --git a/fonts/SmallFont/メ.png b/fonts/SmallFont/メ.png new file mode 100644 index 0000000..d36921a Binary files /dev/null and b/fonts/SmallFont/メ.png differ diff --git a/fonts/SmallFont/モ.png b/fonts/SmallFont/モ.png new file mode 100644 index 0000000..934ee0b Binary files /dev/null and b/fonts/SmallFont/モ.png differ diff --git a/fonts/SmallFont/ャ.png b/fonts/SmallFont/ャ.png new file mode 100644 index 0000000..07df11d Binary files /dev/null and b/fonts/SmallFont/ャ.png differ diff --git a/fonts/SmallFont/ヤ.png b/fonts/SmallFont/ヤ.png new file mode 100644 index 0000000..e59a42e Binary files /dev/null and b/fonts/SmallFont/ヤ.png differ diff --git a/fonts/SmallFont/ュ.png b/fonts/SmallFont/ュ.png new file mode 100644 index 0000000..5805db6 Binary files /dev/null and b/fonts/SmallFont/ュ.png differ diff --git a/fonts/SmallFont/ユ.png b/fonts/SmallFont/ユ.png new file mode 100644 index 0000000..62d13dc Binary files /dev/null and b/fonts/SmallFont/ユ.png differ diff --git a/fonts/SmallFont/ョ.png b/fonts/SmallFont/ョ.png new file mode 100644 index 0000000..c8f3638 Binary files /dev/null and b/fonts/SmallFont/ョ.png differ diff --git a/fonts/SmallFont/ヨ.png b/fonts/SmallFont/ヨ.png new file mode 100644 index 0000000..64df924 Binary files /dev/null and b/fonts/SmallFont/ヨ.png differ diff --git a/fonts/SmallFont/ラ.png b/fonts/SmallFont/ラ.png new file mode 100644 index 0000000..1e6090b Binary files /dev/null and b/fonts/SmallFont/ラ.png differ diff --git a/fonts/SmallFont/リ.png b/fonts/SmallFont/リ.png new file mode 100644 index 0000000..6409fd3 Binary files /dev/null and b/fonts/SmallFont/リ.png differ diff --git a/fonts/SmallFont/ル.png b/fonts/SmallFont/ル.png new file mode 100644 index 0000000..14c98f4 Binary files /dev/null and b/fonts/SmallFont/ル.png differ diff --git a/fonts/SmallFont/レ.png b/fonts/SmallFont/レ.png new file mode 100644 index 0000000..a7b7d06 Binary files /dev/null and b/fonts/SmallFont/レ.png differ diff --git a/fonts/SmallFont/ロ.png b/fonts/SmallFont/ロ.png new file mode 100644 index 0000000..f849d6d Binary files /dev/null and b/fonts/SmallFont/ロ.png differ diff --git a/fonts/SmallFont/ワ.png b/fonts/SmallFont/ワ.png new file mode 100644 index 0000000..15ae7eb Binary files /dev/null and b/fonts/SmallFont/ワ.png differ diff --git a/fonts/SmallFont/ヲ.png b/fonts/SmallFont/ヲ.png new file mode 100644 index 0000000..fa99043 Binary files /dev/null and b/fonts/SmallFont/ヲ.png differ diff --git a/fonts/SmallFont/ン.png b/fonts/SmallFont/ン.png new file mode 100644 index 0000000..161a968 Binary files /dev/null and b/fonts/SmallFont/ン.png differ diff --git a/fonts/SmallFont/・.png b/fonts/SmallFont/・.png new file mode 100644 index 0000000..385e91a Binary files /dev/null and b/fonts/SmallFont/・.png differ diff --git a/fonts/SmallFont/ー.png b/fonts/SmallFont/ー.png new file mode 100644 index 0000000..a7d11d6 Binary files /dev/null and b/fonts/SmallFont/ー.png differ diff --git a/fonts/SmallFont/世.png b/fonts/SmallFont/世.png new file mode 100644 index 0000000..9f00579 Binary files /dev/null and b/fonts/SmallFont/世.png differ diff --git a/fonts/SmallFont/今.png b/fonts/SmallFont/今.png new file mode 100644 index 0000000..69b4f99 Binary files /dev/null and b/fonts/SmallFont/今.png differ diff --git a/fonts/SmallFont/夢.png b/fonts/SmallFont/夢.png new file mode 100644 index 0000000..aadf05c Binary files /dev/null and b/fonts/SmallFont/夢.png differ diff --git a/fonts/SmallFont/奥.png b/fonts/SmallFont/奥.png new file mode 100644 index 0000000..c012c59 Binary files /dev/null and b/fonts/SmallFont/奥.png differ diff --git a/fonts/SmallFont/山.png b/fonts/SmallFont/山.png new file mode 100644 index 0000000..82903a7 Binary files /dev/null and b/fonts/SmallFont/山.png differ diff --git a/fonts/SmallFont/常.png b/fonts/SmallFont/常.png new file mode 100644 index 0000000..1f652fb Binary files /dev/null and b/fonts/SmallFont/常.png differ diff --git a/fonts/SmallFont/我.png b/fonts/SmallFont/我.png new file mode 100644 index 0000000..5127a1f Binary files /dev/null and b/fonts/SmallFont/我.png differ diff --git a/fonts/SmallFont/散.png b/fonts/SmallFont/散.png new file mode 100644 index 0000000..d770b8a Binary files /dev/null and b/fonts/SmallFont/散.png differ diff --git a/fonts/SmallFont/日.png b/fonts/SmallFont/日.png new file mode 100644 index 0000000..8f59713 Binary files /dev/null and b/fonts/SmallFont/日.png differ diff --git a/fonts/SmallFont/有.png b/fonts/SmallFont/有.png new file mode 100644 index 0000000..e492920 Binary files /dev/null and b/fonts/SmallFont/有.png differ diff --git a/fonts/SmallFont/浅.png b/fonts/SmallFont/浅.png new file mode 100644 index 0000000..50c695a Binary files /dev/null and b/fonts/SmallFont/浅.png differ diff --git a/fonts/SmallFont/為.png b/fonts/SmallFont/為.png new file mode 100644 index 0000000..4edea46 Binary files /dev/null and b/fonts/SmallFont/為.png differ diff --git a/fonts/SmallFont/色.png b/fonts/SmallFont/色.png new file mode 100644 index 0000000..2401f89 Binary files /dev/null and b/fonts/SmallFont/色.png differ diff --git a/fonts/SmallFont/見.png b/fonts/SmallFont/見.png new file mode 100644 index 0000000..102241e Binary files /dev/null and b/fonts/SmallFont/見.png differ diff --git a/fonts/SmallFont/越.png b/fonts/SmallFont/越.png new file mode 100644 index 0000000..fd56f29 Binary files /dev/null and b/fonts/SmallFont/越.png differ diff --git a/fonts/SmallFont/酔.png b/fonts/SmallFont/酔.png new file mode 100644 index 0000000..3b1f4eb Binary files /dev/null and b/fonts/SmallFont/酔.png differ diff --git a/fonts/SmallFont/(.png b/fonts/SmallFont/(.png new file mode 100644 index 0000000..240911d Binary files /dev/null and b/fonts/SmallFont/(.png differ diff --git a/fonts/SmallFont/).png b/fonts/SmallFont/).png new file mode 100644 index 0000000..2097e4b Binary files /dev/null and b/fonts/SmallFont/).png differ diff --git a/lithos_c/Makefile b/lithos_c/Makefile index 13929b5..d90486e 100644 --- a/lithos_c/Makefile +++ b/lithos_c/Makefile @@ -40,13 +40,15 @@ SOURCES= \ $(SRC)/context.c \ $(SRC)/control.c \ $(SRC)/draw.c \ - $(SRC)/font.c \ + $(SRC)/fontrun.c \ + $(SRC)/fontnew.c \ $(SRC)/main.c \ $(SRC)/manifest.c \ $(SRC)/stdlib.c \ $(SRC)/token.c \ $(SRC)/tokenstream.c \ - $(SRC)/window.c + $(SRC)/window.c \ + $(SRC)/winman.c HEADERS= \ $(INC)/Lth.h \ @@ -57,7 +59,6 @@ HEADERS= \ $(INC)/Lth_draw.h \ $(INC)/Lth_font.h \ $(INC)/Lth_hashmap.h \ - $(INC)/Lth_hudmessage.h \ $(INC)/Lth_linklist.h \ $(INC)/Lth_manifest.h \ $(INC)/Lth_stdfix.h \ @@ -65,7 +66,8 @@ HEADERS= \ $(INC)/Lth_token.h \ $(INC)/Lth_tokenstream.h \ $(INC)/Lth_types.h \ - $(INC)/Lth_window.h + $(INC)/Lth_window.h \ + $(INC)/Lth_winman.h ## Output diff --git a/lithos_c/inc/Lth.h b/lithos_c/inc/Lth.h index a667dfe..ffb579b 100644 --- a/lithos_c/inc/Lth.h +++ b/lithos_c/inc/Lth.h @@ -22,27 +22,41 @@ #include +// Types, Assert #include "Lth_types.h" #include "Lth_assert.h" + +// stdlib #include "Lth_stdlib.h" +// LinkList, HashMap #include "Lth_linklist.h" #include "Lth_hashmap.h" +// Token #include "Lth_token.h" + +// TokenStream #include "Lth_tokenstream.h" -#include "Lth_callback.h" - +// Manifest #include "Lth_manifest.h" -#include "Lth_font.h" +// Context #include "Lth_context.h" -#include "Lth_control.h" -#include "Lth_button.h" -#include "Lth_window.h" -#include "Lth_hudmessage.h" +// Draw #include "Lth_draw.h" +// Font +#include "Lth_font.h" + +// Control +#include "Lth_callback.h" +#include "Lth_control.h" + +// Control Types +#include "Lth_window.h" +#include "Lth_winman.h" + #endif//lithos3__Lth_h diff --git a/lithos_c/inc/Lth_callback.h b/lithos_c/inc/Lth_callback.h index b709776..0f825d8 100644 --- a/lithos_c/inc/Lth_callback.h +++ b/lithos_c/inc/Lth_callback.h @@ -19,11 +19,11 @@ #if defined(Lth_X) -Lth_X(SIGDESTROY, destroy, void, struct Lth_Control *) -Lth_X(SIGCLICK , click, void, struct Lth_Control *) -Lth_X(SIGDRAW , draw, void, struct Lth_Control *) -Lth_X(SIGPSTDRAW, postdraw, void, struct Lth_Control *) -Lth_X(SIGUPDATE , update, void, struct Lth_Control *) +Lth_X(SigDestroy, destroy, void, struct Lth_Control *) +Lth_X(SigClicked, click, void, struct Lth_Control *) +Lth_X(SigDraw , draw, void, struct Lth_Control *) +Lth_X(SigDrawPst, drawpost, void, struct Lth_Control *) +Lth_X(SigUpdate , update, void, struct Lth_Control *) #undef Lth_X @@ -31,6 +31,7 @@ Lth_X(SIGUPDATE , update, void, struct Lth_Control *) #define lithos3__Lth_callback_h #define Lth_Callback(name) ((Lth_Callback_t)(name)) + #define Lth_Call(name, ...) \ do \ { \ @@ -39,6 +40,7 @@ Lth_X(SIGUPDATE , update, void, struct Lth_Control *) (name).data[cbIter](__VA_ARGS__); \ } \ while(0) + #define Lth_CallReverse(name, ...) \ do \ { \ @@ -47,11 +49,6 @@ Lth_X(SIGUPDATE , update, void, struct Lth_Control *) (name).data[cbIter - 1](__VA_ARGS__); \ } \ while(0) -#define Lth_ControlCall(ctrl, name, ...) \ - Lth_ListForEach(Lth_Control *owner, ctrl->descendants) \ - Lth_Call(owner->cb.name, __VA_ARGS__); \ - \ - Lth_Call(ctrl->cb.name, __VA_ARGS__) // Type Definitions ----------------------------------------------------------| diff --git a/lithos_c/inc/Lth_context.h b/lithos_c/inc/Lth_context.h index 1e71f21..185e9d7 100644 --- a/lithos_c/inc/Lth_context.h +++ b/lithos_c/inc/Lth_context.h @@ -33,32 +33,26 @@ // // internal data // clip -// map // rsrcBase // rsrc -// lastmap // // read-only -// w: width of screen -// h: height of screen +// scale: current draw scale +// w: width of screen +// h: height of screen // // read-write // hid: HUD ID range -// mapspace: space between newly mapped windows that are auto-positioned -// font: default font for drawing // typedef struct Lth_Context { - struct { Lth_Rect rects[16]; int num; } clip; - struct { Lth_LinkList *head, *tail; } map; + struct { Lth_Rect rects[16]; size_t num; } clip; Lth_ResourceMap *rsrcBase, *rsrc; - Lth_IVec2 lastmap; + _Accum scale; int w, h; Lth_HIDRange hid; - Lth_IVec2 mapspace; - Lth_Font *font; } Lth_Context; @@ -68,11 +62,11 @@ Lth_Context *Lth_ContextNew(int w, int h, Lth_HID hidBase, Lth_HID hidEnd); void Lth_ContextDestroy(Lth_Context *ctx); void Lth_ContextRun(Lth_Context *ctx); -void Lth_ContextMap(Lth_Context *ctx, struct Lth_Window *window); - void Lth_ContextClipPush(Lth_Context *ctx, int x, int y, int w, int h); void Lth_ContextClipPop(Lth_Context *ctx); void *Lth_ContextResource(Lth_Context *ctx, char const *key); +void Lth_ContextScale(Lth_Context *ctx, _Accum s); + #endif//lithos3__Lth_context_h diff --git a/lithos_c/inc/Lth_control.h b/lithos_c/inc/Lth_control.h index 6fc8e40..ef7254b 100644 --- a/lithos_c/inc/Lth_control.h +++ b/lithos_c/inc/Lth_control.h @@ -13,6 +13,16 @@ #ifndef lithos3__Lth_control_h #define lithos3__Lth_control_h +#define Lth_ControlFontRunPlain(ctrl, ...) \ + Lth_FontRunPlain((ctrl)->ctx, Lth_ControlFont((ctrl)), __VA_ARGS__) + +#define Lth_ControlInit(type) \ + type *ctrl = calloc(1, sizeof(type)); \ + Lth_assert(ctrl != NULL); \ + \ + ctrl->ctx = ctx + +#define Lth_VirtControl (void *)ctrl // Type Definitions ----------------------------------------------------------| @@ -23,30 +33,37 @@ // Has members of Lth_Rect (read-write). // // internal data -// link -// descendants // cb +// descHead +// descTail +// link // // read-only +// vtable: virtual functions for overrides // parent: control's parent (NULL if none) // // read-write -// userdata: opaque pointer for the user to use -// font: default font for drawing // ctx: pointer to associated context +// font: default font for drawing +// userdata: opaque pointer for the user to use // // typedef struct Lth_Control { Lth_CallbackSet cb; - Lth_LinkList link; - Lth_LinkList *descendants; + + struct + { + Lth_Font *(*getFont)(struct Lth_Control *); + } vtable; + + Lth_LinkList *descHead, *descTail, link; struct Lth_Control *parent; - void *userdata; - Lth_Font *font; Lth_Context *ctx; + Lth_Font *font; + void *userdata; Lth_Mixin(Lth_Rect); } Lth_Control; @@ -54,10 +71,12 @@ typedef struct Lth_Control // Extern Functions ----------------------------------------------------------| -Lth_Font *Lth_ControlFont(void *ctrl_); void Lth_ControlRun(void *ctrl_); void Lth_ControlConnect(void *ctrl_, Lth_Signal signal, Lth_Callback_t cb); void Lth_ControlDestroy(void *ctrl_); -void Lth_ControlAttach(void *ctrlsrc_, void *ctrldst_); +void Lth_ControlAttach(void *ctrl_, void *ctrlS_); +void Lth_ControlAttachTail(void *ctrl_, void *ctrlS_); + +Lth_Font *Lth_ControlFont(void *ctrl_); #endif//lithos3__Lth_control_h diff --git a/lithos_c/inc/Lth_draw.h b/lithos_c/inc/Lth_draw.h index a284221..41c58ef 100644 --- a/lithos_c/inc/Lth_draw.h +++ b/lithos_c/inc/Lth_draw.h @@ -13,9 +13,25 @@ #ifndef lithos3__Lth_draw_h #define lithos3__Lth_draw_h +#define Lth_HudMessageBegin() ACS_BeginPrint() + +#define Lth_TICK (0.029k) // One gametic, in seconds. + +#define Lth_A_Cen (0.0k) +#define Lth_A_Lef (0.1k) +#define Lth_A_Rig (0.2k) +#define Lth_A_Top (0.1k) +#define Lth_A_Bot (0.2k) +#define Lth_A_TCe (0.4k) +#define Lth_A_TLe (0.5k) +#define Lth_A_TRi (0.6k) + // Extern Functions ----------------------------------------------------------| +Lth_OptArgs(1) void Lth_HudMessageEnd(Lth_Context *ctx, _Accum x, _Accum y, _Accum a); +Lth_OptArgs(1) void Lth_DrawSprite(Lth_Context *ctx, __str name, _Accum x, _Accum y, _Accum a); + void Lth_DrawRectAndClip(Lth_Context *ctx, int x, int y, int w, int h, _Accum alpha); void Lth_DrawRect(Lth_Context *ctx, int x, int y, int w, int h, _Accum alpha); diff --git a/lithos_c/inc/Lth_font.h b/lithos_c/inc/Lth_font.h index 71a903d..2b9d252 100644 --- a/lithos_c/inc/Lth_font.h +++ b/lithos_c/inc/Lth_font.h @@ -13,15 +13,54 @@ #ifndef lithos3__Lth_font_h #define lithos3__Lth_font_h +#define Lth_FontRunBegin() ACS_BeginPrint() + // Type Definitions ----------------------------------------------------------| +struct Lth_Context; + +enum +{ + Lth_AX_Lef = 1, + Lth_AX_Rig, + Lth_AX_Cen, + + Lth_AY_Top = 1, + Lth_AY_Bot, + Lth_AY_Cen +}; + +// +// Lth_FontCasing +// +typedef enum Lth_FontCasing +{ + Lth_Case_Both, + Lth_Case_Uppr, + Lth_Case_Lowr +} Lth_FontCasing; + +// +// Lth_GlyphLookupType +// +typedef enum Lth_GlyphLookupType +{ + Lth_GT_Chara, + Lth_GT_Codep, + Lth_GT_Digit +} Lth_GlyphLookupType; + // // Lth_Glyph // typedef struct Lth_Glyph { - int w, h; + Lth_Inherits(Lth_Rect); + __str fname; + _Accum s; + wchar_t ch; + char mb[MB_CUR_MAX + 1]; } Lth_Glyph; // @@ -29,13 +68,22 @@ typedef struct Lth_Glyph // typedef struct Lth_Font { - __str name; - Lth_Glyph glyphs[126]; + Lth_FontCasing casing; + __str baseName; + int spaceWidth; + int height; + __str fnamePref; + __str fnameSuff; + Lth_HashMap glyphs; + Lth_Vector(Lth_Glyph) glyphV; } Lth_Font; // Extern Functions ----------------------------------------------------------| -Lth_Font *Lth_FontNew(char const *name); +Lth_ScriptCall Lth_Font *Lth_FontNew(char const *fname); +void Lth_FontDestroy(Lth_Font *font); + +Lth_OptArgs(2) void Lth_FontRunPlain(struct Lth_Context *ctx, Lth_Font *font, int x, int y, int ax, int ay); #endif//lithos3__Lth_font_h diff --git a/lithos_c/inc/Lth_hashmap.h b/lithos_c/inc/Lth_hashmap.h index 93406d2..cd67803 100644 --- a/lithos_c/inc/Lth_hashmap.h +++ b/lithos_c/inc/Lth_hashmap.h @@ -64,9 +64,9 @@ typedef struct Lth_HashMap // Static Functions ----------------------------------------------------------| // -// Lth_HashMapFree +// Lth_HashMapDestroy // -static inline void Lth_HashMapFree(Lth_HashMap *map) +static inline void Lth_HashMapDestroy(Lth_HashMap *map) { if(map == NULL) return; @@ -82,10 +82,8 @@ static inline void Lth_HashMapFree(Lth_HashMap *map) // static inline void Lth_HashMapAlloc(Lth_HashMap *map, size_t count) { - Lth_assert(map != NULL); - if(map->elem.data) - Lth_HashMapFree(map); + Lth_HashMapDestroy(map); size_t size = sizeof(Lth_HashMapElem) * count + sizeof(Lth_HashMapElem *) * count; @@ -99,8 +97,6 @@ static inline void Lth_HashMapAlloc(Lth_HashMap *map, size_t count) // static inline void Lth_HashMapBuild(Lth_HashMap *map) { - Lth_assert(map != NULL); - map->table = (Lth_HashMapElem **)(map->elem.data + map->elem.size); for(Lth_HashMapElem **elem = map->table + map->elem.size; diff --git a/lithos_c/inc/Lth_hudmessage.h b/lithos_c/inc/Lth_hudmessage.h deleted file mode 100644 index 513d04b..0000000 --- a/lithos_c/inc/Lth_hudmessage.h +++ /dev/null @@ -1,102 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Copyright © 2016 Project Golan -// -// See "LICENSE" for more information. -// -//----------------------------------------------------------------------------- -// -// HudMessage macros. -// -//----------------------------------------------------------------------------- - -#ifndef lithos3__Lth_hudmessage_h -#define lithos3__Lth_hudmessage_h - -#define Lth_HudMessageFont(font, ...) \ - ( \ - ACS_SetFont(font), \ - Lth_HudMessage(__VA_ARGS__) \ - ) - -#define Lth_HudMessageParams(flags, id, tr, x, y, ...) \ - ( \ - ACS_OptHudMessage((flags) | HUDMSG_NOTWITHFULLMAP, id, tr, x, y, \ - Lth_TICK), \ - ACS_EndHudMessage(__VA_ARGS__) \ - ) - -#define Lth_HudMessagePlain(id, x, y) \ - ( \ - ACS_OptHudMessage(HUDMSG_PLAIN | HUDMSG_NOTWITHFULLMAP, id, \ - CR_UNTRANSLATED, x, y, Lth_TICK), \ - ACS_EndHudMessage() \ - ) - -#define Lth_HudMessageFade(id, x, y, fadetime) \ - ( \ - ACS_OptHudMessage(HUDMSG_FADEOUT | HUDMSG_NOTWITHFULLMAP, id, \ - CR_UNTRANSLATED, x, y, Lth_TICK), \ - ACS_EndHudMessage(fadetime) \ - ) - -#define Lth_DrawSprite(name, flags, id, x, y, ...) \ - ( \ - ACS_SetFont(name), \ - ACS_PrintChar('A'), \ - Lth_HudMessageParams((flags) | HUDMSG_NOTWITHFULLMAP, id, \ - CR_UNTRANSLATED, x, y, __VA_ARGS__) \ - ) - -#define Lth_DrawSpriteFade(name, id, x, y, fadetime) \ - ( \ - ACS_SetFont(name), \ - ACS_PrintChar('A'), \ - Lth_HudMessageFade(id, x, y, fadetime) \ - ) - -#define Lth_DrawSpritePlain(name, id, x, y) \ - ( \ - ACS_SetFont(name), \ - ACS_PrintChar('A'), \ - Lth_HudMessagePlain(id, x, y) \ - ) - -#define Lth_DrawSpriteAlpha(name, id, x, y, alpha) \ - ( \ - ACS_SetFont(name), \ - ACS_PrintChar('A'), \ - Lth_HudMessageParams(HUDMSG_ALPHA, id, CR_UNTRANSLATED, x, y, alpha) \ - ) - -#define Lth_TICK (0.029k) // One tick, in seconds. - -#define Lth_A_Cen (0.0k) -#define Lth_A_Lef (0.1k) -#define Lth_A_Rig (0.2k) -#define Lth_A_Top (0.1k) -#define Lth_A_Bot (0.2k) -#define Lth_A_TCen (0.4k) -#define Lth_A_TLef (0.5k) -#define Lth_A_TRig (0.6k) - - -// Static Functions ----------------------------------------------------------| - -// -// Lth_HudMessage -// -static inline void Lth_HudMessage(char const *fmt, ...) -{ - va_list vl; - - ACS_BeginPrint(); - - va_start(vl, fmt); - __vnprintf(fmt, vl); - va_end(vl); - - ACS_MoreHudMessage(); -} - -#endif//lithos3__Lth_hudmessage_h diff --git a/lithos_c/inc/Lth_linklist.h b/lithos_c/inc/Lth_linklist.h index 4eaa595..3cac0b2 100644 --- a/lithos_c/inc/Lth_linklist.h +++ b/lithos_c/inc/Lth_linklist.h @@ -59,9 +59,6 @@ typedef struct Lth_LinkList // static inline void Lth_ListLink(Lth_LinkList *list, Lth_LinkList **head) { - Lth_assert(list != NULL); - Lth_assert(head != NULL); - Lth_LinkList *next = *head; if((list->next = next)) @@ -77,10 +74,6 @@ static inline void Lth_ListLink(Lth_LinkList *list, Lth_LinkList **head) static inline void Lth_ListLinkTail(Lth_LinkList *list, Lth_LinkList **head, Lth_LinkList **tail) { - Lth_assert(list != NULL); - Lth_assert(head != NULL); - Lth_assert(tail != NULL); - Lth_LinkList *prev = *tail; if(*(list->prev = head)) @@ -97,8 +90,6 @@ static inline void Lth_ListLinkTail(Lth_LinkList *list, Lth_LinkList **head, // static inline void Lth_ListRemove(Lth_LinkList *list) { - Lth_assert(list != NULL); - Lth_LinkList *next = list->next, **prev = list->prev; if(prev && (*prev = next)) diff --git a/lithos_c/inc/Lth_window.h b/lithos_c/inc/Lth_window.h index ead4540..fb583bf 100644 --- a/lithos_c/inc/Lth_window.h +++ b/lithos_c/inc/Lth_window.h @@ -33,7 +33,7 @@ typedef struct Lth_Window // Extern Functions ----------------------------------------------------------| -Lth_OptArgs(2) Lth_Window *Lth_WindowNew(char const *title, int x, int y, int w, int h); +Lth_OptArgs(2) Lth_Window *Lth_WindowNew(Lth_Context *ctx, char const *title, int x, int y, int w, int h); void Lth_WindowSetTitle(Lth_Window *ctrl, char const *title); #endif//lithos3__Lth_window_h diff --git a/lithos_c/inc/Lth_winman.h b/lithos_c/inc/Lth_winman.h new file mode 100644 index 0000000..05377d1 --- /dev/null +++ b/lithos_c/inc/Lth_winman.h @@ -0,0 +1,45 @@ +//----------------------------------------------------------------------------- +// +// Copyright © 2016 Project Golan +// +// See "LICENSE" for more information. +// +//----------------------------------------------------------------------------- +// +// Window management. +// +//----------------------------------------------------------------------------- + +#ifndef lithos3__Lth_winman_h +#define lithos3__Lth_winman_h + + +// Type Definitions ----------------------------------------------------------| + +// +// Lth_WindowManager +// +// Inherits Lth_Control (read-write) +// +// internal data +// lastmap +// +// read-write +// mapspace: space between newly mapped windows that are auto-positioned +// +typedef struct Lth_WindowManager +{ + Lth_Inherits(Lth_Control); + + Lth_IVec2 lastmap; + + Lth_IVec2 mapspace; +} Lth_WindowManager; + + +// Extern Functions ----------------------------------------------------------| + +Lth_WindowManager *Lth_WMNew(Lth_Context *ctx); +void Lth_WMMap(Lth_WindowManager *wm, Lth_Window *window); + +#endif//lithos3__Lth_winman_h diff --git a/lithos_c/src/context.c b/lithos_c/src/context.c index 119f49d..40d3f7f 100644 --- a/lithos_c/src/context.c +++ b/lithos_c/src/context.c @@ -12,26 +12,6 @@ #include "Lth.h" -#include -#include -#include - - -// Static Functions ----------------------------------------------------------| - -// -// Lth_ContextSetup -// -static void Lth_ContextSetup(Lth_Context *ctx, void *ctrl_) -{ - Lth_Control *ctrl = ctrl_; - - Lth_ListForEach(Lth_Control *owner, ctrl->descendants) - Lth_ContextSetup(ctx, owner); - - ctrl->ctx = ctx; -} - // Extern Functions ----------------------------------------------------------| @@ -41,18 +21,15 @@ static void Lth_ContextSetup(Lth_Context *ctx, void *ctrl_) Lth_Context *Lth_ContextNew(int w, int h, Lth_HID hidBase, Lth_HID hidEnd) { Lth_Context *ctx = calloc(1, sizeof(Lth_Context)); - Lth_assert(ctx != NULL); + ctx->scale = 1.0k; ctx->w = w; ctx->h = h; - ctx->lastmap.x = ctx->lastmap.y = -1; ctx->hid.cur = ctx->hid.base = hidBase; ctx->hid.end = hidEnd; - ctx->mapspace.x = 24; - ctx->mapspace.y = 16; ctx->rsrcBase = Lth_ManifestLoad_static(Lth_ManifestNew( - Lth_Resource("Base.Resource1", 999) + Lth_Resource("Base.DefaultFont", "lithos_fs/Fonts/SmallFontJP.lthm") )); return ctx; @@ -63,18 +40,7 @@ Lth_Context *Lth_ContextNew(int w, int h, Lth_HID hidBase, Lth_HID hidEnd) // void Lth_ContextDestroy(Lth_Context *ctx) { - if(ctx == NULL) - return; - - if(ctx->map.head) - { - Lth_ListFor(Lth_Control *owner, ctx->map.head) - { - Lth_ListRemove(list); - if(owner) Lth_ControlDestroy(owner); - list = next; - } - } + if(ctx == NULL) return; Lth_ResourceMapDestroy(ctx->rsrc); Lth_ResourceMapDestroy(ctx->rsrcBase); @@ -87,32 +53,12 @@ void Lth_ContextDestroy(Lth_Context *ctx) // void Lth_ContextRun(Lth_Context *ctx) { - Lth_assert(ctx != NULL); + Lth_Rect rect = ctx->clip.rects[ctx->clip.num]; ACS_SetHudSize(ctx->w, ctx->h, true); + ACS_SetHudClipRect(rect.x, rect.y, rect.w, rect.h); + ctx->hid.cur = ctx->hid.base; - - if(ctx->map.head) - Lth_ListForEach(Lth_Control *owner, ctx->map.head) - Lth_ControlRun(owner); -} - -// -// Lth_ContextMap -// -void Lth_ContextMap(Lth_Context *ctx, Lth_Window *ctrl) -{ - Lth_assert(ctx != NULL); - Lth_assert(ctrl != NULL); - - if(ctrl->x == -1) ctrl->x = ctx->lastmap.x += ctx->mapspace.x; - else ctx->lastmap.x = ctrl->x; - - if(ctrl->y == -1) ctrl->y = ctx->lastmap.y += ctx->mapspace.y; - else ctx->lastmap.y = ctrl->y; - - Lth_ContextSetup(ctx, ctrl); - Lth_ListInsertTail(&ctrl->link, ctrl, &ctx->map.head, &ctx->map.tail); } // @@ -120,8 +66,6 @@ void Lth_ContextMap(Lth_Context *ctx, Lth_Window *ctrl) // void Lth_ContextClipPush(Lth_Context *ctx, int x, int y, int w, int h) { - Lth_assert(ctx != NULL); - Lth_Rect rect = ctx->clip.rects[ctx->clip.num++]; if(!(rect.x == 0 && rect.y == 0 && rect.w == 0 && rect.h == 0)) @@ -143,8 +87,6 @@ void Lth_ContextClipPush(Lth_Context *ctx, int x, int y, int w, int h) // void Lth_ContextClipPop(Lth_Context *ctx) { - Lth_assert(ctx != NULL); - Lth_Rect rect = ctx->clip.rects[--ctx->clip.num]; ACS_SetHudClipRect(rect.x, rect.y, rect.w, rect.h); } @@ -154,9 +96,19 @@ void Lth_ContextClipPop(Lth_Context *ctx) // void *Lth_ContextResource(Lth_Context *ctx, char const *key) { - void *p = Lth_HashMapFind(&ctx->rsrc->map, key); - if(p) return p; - else return Lth_HashMapFind(&ctx->rsrcBase->map, key); + void *p = NULL; + if(ctx->rsrc) p = Lth_HashMapFind(&ctx->rsrc->map, key); + if(p) return p; + else return Lth_HashMapFind(&ctx->rsrcBase->map, key); +} + +// +// Lth_ContextScale +// +void Lth_ContextScale(Lth_Context *ctx, _Accum s) +{ + ctx->scale = s; + ACS_SetHudSize(ctx->w / ctx->scale, ctx->h / ctx->scale, true); } // EOF diff --git a/lithos_c/src/control.c b/lithos_c/src/control.c index 4e28042..e2dfc27 100644 --- a/lithos_c/src/control.c +++ b/lithos_c/src/control.c @@ -19,27 +19,6 @@ // Extern Functions ----------------------------------------------------------| -// -// Lth_ControlFont -// -Lth_Font *Lth_ControlFont(void *ctrl_) -{ - Lth_Control *ctrl = ctrl_; - - if(ctrl->font) - return ctrl->font; - else - { - for(Lth_Control *p = ctrl->parent; p; p = p->parent) - { - if(p->font) - return p->font; - } - } - - return ctrl->ctx->font; -} - // // Lth_ControlRun // @@ -47,11 +26,12 @@ void Lth_ControlRun(void *ctrl_) { Lth_Control *ctrl = ctrl_; - Lth_assert(ctrl != NULL); + Lth_ListForEach(Lth_Control *owner, ctrl->descHead) + Lth_ControlRun(owner); - Lth_ControlCall(ctrl, update, ctrl); - Lth_ControlCall(ctrl, draw, ctrl); - Lth_ControlCall(ctrl, postdraw, ctrl); + Lth_Call(ctrl->cb.update, ctrl); + Lth_Call(ctrl->cb.draw, ctrl); + Lth_Call(ctrl->cb.drawpost, ctrl); } // @@ -59,9 +39,7 @@ void Lth_ControlRun(void *ctrl_) // void Lth_ControlConnect(void *ctrl_, Lth_Signal signal, Lth_Callback_t cb) { - Lth_assert(ctrl_ != NULL); Lth_assert(signal < Lth_SIGMAX && signal >= 0); - Lth_assert(cb != NULL); Lth_Control *ctrl = ctrl_; @@ -86,7 +64,7 @@ void Lth_ControlDestroy(void *ctrl_) Lth_Control *ctrl = ctrl_; - Lth_ListFor(Lth_Control *owner, ctrl->descendants) + Lth_ListFor(Lth_Control *owner, ctrl->descHead) { Lth_ControlDestroy(owner); list = next; @@ -105,14 +83,38 @@ void Lth_ControlDestroy(void *ctrl_) // // Lth_ControlAttach // -void Lth_ControlAttach(void *ctrlsrc_, void *ctrldst_) +void Lth_ControlAttach(void *ctrl_, void *ctrlS_) { - Lth_assert(ctrlsrc_ != NULL); - Lth_assert(ctrldst_ != NULL); + Lth_Control *ctrl = ctrl_, *ctrlS = ctrlS_; + Lth_ListInsert(&ctrlS->link, ctrlS, &ctrl->descHead); + ctrlS->ctx = ctrl->ctx; + ctrlS->parent = ctrl; +} - Lth_Control *ctrlsrc = ctrlsrc_, *ctrldst = ctrldst_; - Lth_ListInsert(&ctrlsrc->link, ctrlsrc, &ctrldst->descendants); - ctrlsrc->ctx = ctrldst->ctx; +// +// Lth_ControlAttachTail +// +void Lth_ControlAttachTail(void *ctrl_, void *ctrlS_) +{ + Lth_Control *ctrl = ctrl_, *ctrlS = ctrlS_; + Lth_ListInsertTail(&ctrlS->link, ctrlS, &ctrl->descHead, &ctrl->descTail); + ctrlS->ctx = ctrl->ctx; + ctrlS->parent = ctrl; +} + +// +// Lth_ControlFont +// +Lth_Font *Lth_ControlFont(void *ctrl_) +{ + Lth_Control *ctrl = ctrl_; + + if(ctrl->font || (ctrl->vtable.getFont && ctrl->vtable.getFont(ctrl))) + return ctrl->font; + else if(ctrl->parent) + return Lth_ControlFont(ctrl->parent); + else + return NULL; } // EOF diff --git a/lithos_c/src/draw.c b/lithos_c/src/draw.c index c0ac918..e56b48e 100644 --- a/lithos_c/src/draw.c +++ b/lithos_c/src/draw.c @@ -15,19 +15,52 @@ // Extern Functions ----------------------------------------------------------| +// +// Lth_HudMessageEnd +// +void Lth_HudMessageEnd(Lth_Context *ctx, _Accum x, _Accum y, _Accum a) +{ + int flags = HUDMSG_PLAIN | HUDMSG_NOTWITHFULLMAP; + + if(ctx->scale != 1) + { + long _Accum xn = (int)x / (long _Accum)ctx->w; + long _Accum yn = (int)y / (long _Accum)ctx->h; + x = (xn * (ctx->w / ctx->scale)) + Lth_fractk(x); + y = (yn * (ctx->h / ctx->scale)) + Lth_fractk(y); + } + + if(a) flags |= HUDMSG_ALPHA; + + ACS_MoreHudMessage(); + ACS_OptHudMessage(flags, ctx->hid.cur--, CR_UNTRANSLATED, x, y, Lth_TICK); + if(a) ACS_EndHudMessage(a); + else ACS_EndHudMessage(); +} + +// +// Lth_DrawSprite +// +void Lth_DrawSprite(Lth_Context *ctx, __str name, _Accum x, _Accum y, _Accum a) +{ + ACS_SetFont(name); + + Lth_HudMessageBegin(); + ACS_PrintChar('A'); + Lth_HudMessageEnd(ctx, x, y, a); +} + // // Lth_DrawRectAndClip // void Lth_DrawRectAndClip(Lth_Context *ctx, int x, int y, int w, int h, _Accum alpha) { - Lth_assert(ctx != NULL); - Lth_ContextClipPush(ctx, x, y, w, h); for(int ix = 0; ix < w; ix += 128) for(int iy = 0; iy < h; iy += 128) - Lth_DrawSpriteAlpha(s"lithos_gfx/Base/Black128.png", ctx->hid.cur--, + Lth_DrawSprite(ctx, s"lithos_gfx/Base/Black128.png", x + ix + Lth_A_Lef, y + iy + Lth_A_Top, alpha); } diff --git a/lithos_c/src/font.c b/lithos_c/src/font.c deleted file mode 100644 index 7da4f96..0000000 --- a/lithos_c/src/font.c +++ /dev/null @@ -1,33 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Copyright © 2016 Project Golan -// -// See "LICENSE" for more information. -// -//----------------------------------------------------------------------------- -// -// Font layout handling. -// -//----------------------------------------------------------------------------- - -#include "Lth.h" - -#include - - -// Extern Functions ----------------------------------------------------------| - -// -// Lth_FontNew -// -Lth_Font *Lth_FontNew(char const *name) -{ - Lth_Font *font = calloc(1, sizeof(Lth_Font)); - Lth_assert(font != NULL); - - font->name = Lth_strentdup(name); - - return font; -} - -// EOF diff --git a/lithos_c/src/fontnew.c b/lithos_c/src/fontnew.c new file mode 100644 index 0000000..9006614 --- /dev/null +++ b/lithos_c/src/fontnew.c @@ -0,0 +1,250 @@ +//----------------------------------------------------------------------------- +// +// Copyright © 2016 Project Golan +// +// See "LICENSE" for more information. +// +//----------------------------------------------------------------------------- +// +// Font creation. +// +//----------------------------------------------------------------------------- + +#include "Lth.h" + +#include +#include +#include + +#define GenFontData() \ + char const **base = Lth_HashMapFind(&rsrc->map, "Font.Base"); \ + char const **casing = Lth_HashMapFind(&rsrc->map, "Font.Case"); \ + char const **extraDir = Lth_HashMapFind(&rsrc->map, "Font.ExtraDir"); \ + char const **glyphList = Lth_HashMapFind(&rsrc->map, "Font.Glyphs"); \ + int const *height = Lth_HashMapFind(&rsrc->map, "Font.Height"); \ + char const **prefix = Lth_HashMapFind(&rsrc->map, "Font.Prefix"); \ + int const *spaceWidth = Lth_HashMapFind(&rsrc->map, "Font.SpaceWidth"); \ + char const **suffix = Lth_HashMapFind(&rsrc->map, "Font.Suffix"); \ + char const **typeStr = Lth_HashMapFind(&rsrc->map, "Font.Type"); + +#define FontError(err) \ + if(1) \ + { \ + fprintf(stderr, "%s: %s\n", __func__, err); \ + longjmp(FontJmpBuf, FontJmpBufToken); \ + } \ + else ((void)0) + + +// Static Objects ------------------------------------------------------------| + +static jmp_buf FontJmpBuf; +static int const FontJmpBufToken = 31; + + +// Static Functions ----------------------------------------------------------| + +// +// FontValidate +// +static void FontValidate(Lth_ResourceMap *rsrc) +{ + GenFontData(); + + if(!glyphList) FontError("Font definition must have a glyph list."); + if(!base && !extraDir) FontError("Font definition doesn't have a font."); + if(!height) FontError("Font definition doesn't have a height."); +} + +// +// FontLoadGlyphs +// +static void FontLoadGlyphs(Lth_Font volatile *font, Lth_ResourceMap *rsrc, + int type) +{ + char const **glyphList = Lth_HashMapFind(&rsrc->map, "Font.Glyphs"); + + wchar_t *tmpkey = Lth_wcsdup(L"Font.GlyphData. _ "); + wchar_t *keyl = wcschr(tmpkey, ' '); + wchar_t *keyr = wcsrchr(tmpkey, ' '); + + __with(mbstate_t state; size_t i = 0; memset(&state, 0, sizeof(state));) + for(char const *sptr = *glyphList; *sptr; i++) + { + wchar_t wc; + int ret = mbrtowc(&wc, sptr, 4, &state); + if(ret <= 0) FontError("Error parsing Unicode sequence."); + + Lth_Glyph glyph = { .ch = wc }; + memmove(glyph.mb, sptr, ret); + + (*keyl = wc); + int *x = (*keyr = 'x', Lth_HashMapFind(&rsrc->map, tmpkey)); + int *y = (*keyr = 'y', Lth_HashMapFind(&rsrc->map, tmpkey)); + int *w = (*keyr = 'w', Lth_HashMapFind(&rsrc->map, tmpkey)); + int *h = (*keyr = 'h', Lth_HashMapFind(&rsrc->map, tmpkey)); + _Accum *s = (*keyr = 's', Lth_HashMapFind(&rsrc->map, tmpkey)); + + if(x) glyph.x = *x; + if(y) glyph.y = *y; + if(w) glyph.w = *w; + if(h) glyph.h = *h; + if(s) glyph.s = *s; + + if(wc > 0x7F) + { + ACS_BeginPrint(); + + ACS_PrintString(font->fnamePref); + + switch(type) + { + case Lth_GT_Chara: Lth_PrintString(glyph.mb); break; + case Lth_GT_Codep: ACS_PrintHex(glyph.ch); break; + case Lth_GT_Digit: ACS_PrintInt(glyph.ch); break; + } + + ACS_PrintString(font->fnameSuff); + + glyph.fname = ACS_EndStrParam(); + } + + font->glyphV.data[i] = glyph; + font->glyphs.elem.data[i].keyhash = (size_t)wc; + font->glyphs.elem.data[i].value = &font->glyphV.data[i]; + + sptr += ret; + } + + free(tmpkey); + + Lth_HashMapBuild((Lth_HashMap *)&font->glyphs); +} + +// +// FontSetup +// +static void FontSetup(Lth_Font volatile *font, Lth_ResourceMap *rsrc) +{ + GenFontData(); + + int type; + + if(typeStr) + if(Lth_stricmp(*typeStr, "Character") == 0) type = Lth_GT_Chara; + else if(Lth_stricmp(*typeStr, "Codepoint") == 0) type = Lth_GT_Codep; + else if(Lth_stricmp(*typeStr, "Digit") == 0) type = Lth_GT_Digit; + else FontError("Invalid Font.Type"); + else + type = Lth_GT_Chara; + + font->height = *height; + + if(base) + font->baseName = Lth_strentdup(*base); + + if(extraDir) + { + ACS_BeginPrint(); + + Lth_PrintString(*extraDir); + + if((*extraDir)[strlen(*extraDir)] != '/') + ACS_PrintChar('/'); + + if(prefix) + Lth_PrintString(*prefix); + + font->fnamePref = ACS_EndStrParam(); + + if(suffix) font->fnameSuff = Lth_strentdup(*suffix); + else font->fnameSuff = s".png"; + } + + if(spaceWidth) font->spaceWidth = *spaceWidth; + else font->spaceWidth = 4; + + if(casing) + if(Lth_stricmp(*casing, "Both") == 0) + font->casing = Lth_Case_Both; + else if(Lth_stricmp(*casing, "UpperOnly") == 0) + font->casing = Lth_Case_Uppr; + else if(Lth_stricmp(*casing, "LowerOnly") == 0) + font->casing = Lth_Case_Lowr; + else + FontError("Invalid Font.Case"); + else + font->casing = Lth_Case_Both; + + font->glyphV.size = Lth_mbslen(*glyphList); + Lth_HashMapAlloc((Lth_HashMap *)&font->glyphs, font->glyphV.size); + Lth_VectorAlloc(Lth_Glyph, font->glyphV); + + FontLoadGlyphs(font, rsrc, type); +} + +// +// FontPrint +// +// [debug] Print characters out. +// +Lth_ScriptCall static void FontPrint(Lth_Font *font) +{ + for(size_t i = 0; i < font->glyphs.elem.size; i++) + __with(Lth_Glyph *glyph = font->glyphs.elem.data[i].value;) + printf("glyph %X (%s)\t\tx: %i\ty: %i\tw: %i\n", + glyph->ch, glyph->mb, glyph->x, glyph->y, glyph->w); +} + + +// Extern Functions ----------------------------------------------------------| + +// +// Lth_FontNew +// +Lth_ScriptCall Lth_Font *Lth_FontNew(char const *fname) +{ + Lth_Font volatile *font = NULL; + Lth_ResourceMap *rsrc = NULL; + + // Set up error handler. + if(setjmp(FontJmpBuf) == FontJmpBufToken) + { + if(font) Lth_FontDestroy((Lth_Font *)font); + if(rsrc) Lth_ResourceMapDestroy(rsrc); + + return NULL; + } + + rsrc = Lth_ManifestLoad_extern(fname); + + if(rsrc == NULL) + FontError("Couldn't load resource manifest."); + + FontValidate(rsrc); + + font = calloc(1, sizeof(Lth_Font)); + + if(font == NULL) + FontError("Failed to allocate font."); + + FontSetup(font, rsrc); + + Lth_ResourceMapDestroy(rsrc); + + return (Lth_Font *)font; +} + +// +// Lth_FontDestroy +// +void Lth_FontDestroy(Lth_Font *font) +{ + if(font == NULL) return; + + Lth_HashMapDestroy(&font->glyphs); + free(font->glyphV.data); + free(font); +} + +// EOF diff --git a/lithos_c/src/fontrun.c b/lithos_c/src/fontrun.c new file mode 100644 index 0000000..0df3259 --- /dev/null +++ b/lithos_c/src/fontrun.c @@ -0,0 +1,330 @@ +//----------------------------------------------------------------------------- +// +// Copyright © 2016 Project Golan +// +// See "LICENSE" for more information. +// +//----------------------------------------------------------------------------- +// +// Font rendering. +// +//----------------------------------------------------------------------------- + +#include "Lth.h" + +#include +#include +#include "Lth_stdfix.h" + +#define FontCheckASCII(rst) if((rst)->asciiPrint) FontRenderAPr((rst)) + + +// Type Definitions ----------------------------------------------------------| + +typedef struct FontRenderState +{ + Lth_Context *ctx; + Lth_Font *font; + bool asciiPrint; + _Accum ax, ay; + int x, y; + int tmpx; + int origx, origy; +} FontRenderState; + + +// Static Objects ------------------------------------------------------------| + +static Lth_Glyph FontReplacementGlyph = { + .fname = s"lithos_gfx/ReplacementCharacter.png", + .ch = 0xFFFD, + .mb = u8"�", + .w = 32, + .h = 32, + .s = -1 +}; + + +// Static Functions ----------------------------------------------------------| + +// +// ASCII Character +// Advance Line +// ASCII Print +// Advance Space +// Advance Tabulator +// Character +// Finish +// Glyph +// Return Line +// Wide Character +// +static void FontRenderACh(FontRenderState *rst, Lth_Glyph *glyph); +static void FontRenderALn(FontRenderState *rst); +static void FontRenderAPr(FontRenderState *rst); +static void FontRenderASp(FontRenderState *rst, int amt); +static void FontRenderATa(FontRenderState *rst); +static void FontRenderChr(FontRenderState *rst, wchar_t wc); +static void FontRenderFin(FontRenderState *rst); +static void FontRenderGly(FontRenderState *rst, Lth_Glyph *glyph); +static void FontRenderRLn(FontRenderState *rst); +static void FontRenderWCh(FontRenderState *rst, wchar_t wc, bool noascii); + +// +// FontRenderACh +// +static void FontRenderACh(FontRenderState *rst, Lth_Glyph *glyph) +{ + if(!rst->asciiPrint) + { + Lth_HudMessageBegin(); + rst->asciiPrint = true; + } + + rst->tmpx += glyph->w; + ACS_PrintChar(glyph->ch); + +#if Lth_DEBUG_FONTRUN + printf("ASCII_CHAR[%c] ", glyph->ch); +#endif +} + +// +// FontRenderALn +// +static void FontRenderALn(FontRenderState *rst) +{ + FontCheckASCII(rst); + + rst->y += rst->font->height; + +#if Lth_DEBUG_FONTRUN + printf("NEWLINE "); +#endif +} + +// +// FontRenderAPr +// +static void FontRenderAPr(FontRenderState *rst) +{ + rst->asciiPrint = false; + + if(rst->font->baseName) + { + _Accum x = rst->x + rst->ax; + _Accum y = rst->y + rst->ay; + +#if Lth_DEBUG_FONTRUN + printf("ASCII_PRINT[%.2k, %.2k] ", x, y); +#endif + + ACS_SetFont(rst->font->baseName); + Lth_HudMessageEnd(rst->ctx, x, y); + + rst->x += rst->tmpx; + rst->tmpx = 0; + } + else + { + __str s = ACS_EndStrParam(); + int len = ACS_StrLen(s); + + for(int i = 0; i < len; i++) + FontRenderWCh(rst, s[i], true); + } +} + +// +// FontRenderASp +// +static void FontRenderASp(FontRenderState *rst, int amt) +{ + FontCheckASCII(rst); + + rst->x += rst->font->spaceWidth * amt; + +#if Lth_DEBUG_FONTRUN + printf("SPACE[%i] ", amt); +#endif +} + +// +// FontRenderATa +// +static void FontRenderATa(FontRenderState *rst) +{ + FontCheckASCII(rst); + + int tabw = rst->font->spaceWidth * 8; + rst->x = Lth_ceilk(rst->x / (_Accum)tabw) * tabw; + +#if Lth_DEBUG_FONTRUN + printf("TABULATOR "); +#endif +} + +// +// FontRenderChr +// +static void FontRenderChr(FontRenderState *rst, wchar_t wc) +{ + switch(wc) + { + case L' ': FontRenderASp(rst, 1); break; + case 0x3000: FontRenderASp(rst, 2); break; + case L'\t': FontRenderATa(rst); break; + case L'\n': FontRenderALn(rst); + case L'\r': FontRenderRLn(rst); break; + default: FontRenderWCh(rst, wc, false); break; + } +} + +// +// FontRenderFin +// +static void FontRenderFin(FontRenderState *rst) +{ + FontCheckASCII(rst); + +#if Lth_DEBUG_FONTRUN + printf("DONE\n"); +#endif +} + +// +// FontRenderGly +// +static void FontRenderGly(FontRenderState *rst, Lth_Glyph *glyph) +{ + FontCheckASCII(rst); + + _Accum w = glyph->w; + + _Accum scale = 0; + + if(glyph->s != 0) + { + if(glyph->s < 0) scale = rst->font->height / (_Accum)glyph->h; + else scale = glyph->s; + + w *= scale; + } + + if(scale) + Lth_ContextScale(rst->ctx, scale); + + _Accum x = (rst->x + glyph->x) + rst->ax; + _Accum y = (rst->y + glyph->y) + rst->ax; + +#if Lth_DEBUG_FONTRUN + printf("GLYPH[%s][%.2k, %.2k] ", glyph->mb, x, y); +#endif + + Lth_DrawSprite(rst->ctx, glyph->fname, x, y); + + if(scale) + Lth_ContextScale(rst->ctx, 1); + + rst->x += w; +} + +// +// FontRenderRLn +// +static void FontRenderRLn(FontRenderState *rst) +{ + FontCheckASCII(rst); + + rst->x = rst->origx; + +#if Lth_DEBUG_FONTRUN + printf("RET_LINE "); +#endif +} + +// +// FontRenderWCh +// +static void FontRenderWCh(FontRenderState *rst, wchar_t wc, bool noascii) +{ + switch(rst->font->casing) + { + case Lth_Case_Both: default: break; + case Lth_Case_Uppr: if(wc >= L'a' && wc <= L'z') wc -= 0x20; break; + case Lth_Case_Lowr: if(wc >= L'A' && wc <= L'Z') wc += 0x20; break; + } + +#if Lth_DEBUG_FONTRUN + printf("CH "); +#endif + + Lth_Glyph *glyph = Lth_HashMapFind(&rst->font->glyphs, wc); + if(glyph == NULL) glyph = &FontReplacementGlyph; + + if(glyph->ch > 0x7F || noascii) FontRenderGly(rst, glyph); + else FontRenderACh(rst, glyph); +} + + +// Extern Functions ----------------------------------------------------------| + +// +// Lth_FontRunPlain +// +void Lth_FontRunPlain(Lth_Context *ctx, Lth_Font *font, int x, int y, + int ax, int ay) +{ + if(font == NULL) + { + ACS_EndStrParam(); + return; + } + + FontRenderState rst = { + .ctx = ctx, + .font = font, + .x = x, .y = y, + .origx = x, .origy = y + }; + + switch(ax) + { + default: case Lth_AX_Lef: rst.ax = 0.1k; break; + case Lth_AX_Rig: rst.ax = 0.2k; break; + case Lth_AX_Cen: rst.ax = 0.0k; break; + } + + switch(ay) + { + default: case Lth_AY_Top: rst.ay = 0.1k; break; + case Lth_AY_Bot: rst.ay = 0.2k; break; + case Lth_AY_Cen: rst.ay = 0.0k; break; + } + + char *str = Lth_strdup_str(ACS_EndStrParam()); + + Lth_WithMbState() + for(char const *sptr = str; *sptr;) + { + wchar_t wc; + int ret = mbrtowc(&wc, sptr, 4, &state); + +#if Lth_DEBUG_FONTRUN + printf("%i: ", ret); +#endif + + if(ret > 0) FontRenderChr(&rst, wc), sptr += ret; + else FontRenderGly(&rst, &FontReplacementGlyph), sptr += -ret; + +#if Lth_DEBUG_FONTRUN + printf("\n"); +#endif + } + + FontRenderFin(&rst); + + free(str); +} + +// EOF diff --git a/lithos_c/src/main.c b/lithos_c/src/main.c index c1e42b5..fbfced1 100644 --- a/lithos_c/src/main.c +++ b/lithos_c/src/main.c @@ -15,6 +15,8 @@ #include #include +#define Test_Text + // Static Functions ----------------------------------------------------------| @@ -23,28 +25,75 @@ static void main() { Lth_Context *ctx = Lth_ContextNew(320, 200, 0x5000, 0x1000); - Lth_ContextManifestLoad_extern(ctx, "lithos_fs/Base.lthm"); +#if defined(Test_Text) - ctx->mapspace.x = ctx->mapspace.y = 32; + char const *test = + u8" ɢ ᴜ ᴅ\n" + "ASCII test\n" + "!\"#$%&'()*+,-./0123456789:;<=>?@A\n" + "BCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_\n\n" + "kanalang test\n" + "ァサラルコ(エワイホロア♥ツレカク\n" + "スノタヘチォメテケウョシヲーキマ\n" + "ドニリヤゥソムフミンィェト、セ\n" + "ュハユヒ。ャオモッヌ〜ヨ)ナネ\n\n" + "Spacing and missing character test\n" + "The quick b\trown fox jumps over\n" + "the lazy, ta\tbulated dog.ᴇᴇ\n\n" + "Iroha\n" + "色はにほへど 散りぬるを\n" + "我が世たれぞ 常ならむ・\n" + "有為の奥山  今日越えて\n" + "浅き夢見じ  酔ひもせず"; - Lth_Window *window[] = { - Lth_WindowNew("test window", -1, -1, 50, 100), - Lth_WindowNew("test window 2", -1, -1, 100, 100), - Lth_WindowNew("test window 3", -1, -1, 100, 30), - Lth_WindowNew("test window 4", -1, -1, 100, 100), - }; - - for(int i = 0; i < sizeof(window) / sizeof(*window); i++) - Lth_ContextMap(ctx, window[i]); - - ACS_Delay(1); + char const **defFont = Lth_ContextResource(ctx, "Base.DefaultFont"); + Lth_Font *font = Lth_FontNew(*defFont); for(;;) { Lth_ContextRun(ctx); + + Lth_FontRunBegin(); + Lth_PrintString(test); + Lth_FontRunPlain(ctx, font, 40, 20); + ACS_Delay(1); } +#elif defined(Test_Windowing) + + Lth_WindowManager *wm = Lth_WMNew(ctx); + + Lth_Window *window[] = { + Lth_WindowNew(ctx, "test window", -1, -1, 50, 100), + Lth_WindowNew(ctx, u8"テスト ウィンドー 2", -1, -1, 100, 100), + Lth_WindowNew(ctx, "test window 3", -1, -1, 100, 30), + Lth_WindowNew(ctx, "test window 4", -1, -1, 100, 100) + }; + + for(int i = 0; i < 4; i++) + Lth_WMMap(wm, window[i]); + + for(;;) + { + Lth_ContextRun(ctx); + Lth_ControlRun(wm); + ACS_Delay(1); + } + +#elif defined(Test_NoWM) + + Lth_Window *window = Lth_WindowNew(ctx, "test window", 20, 20, 100, 100); + + for(;;) + { + Lth_ContextRun(ctx); + Lth_ControlRun(window); + ACS_Delay(1); + } + +#endif + Lth_ContextDestroy(ctx); } diff --git a/lithos_c/src/manifest.c b/lithos_c/src/manifest.c index 4db033c..68e690a 100644 --- a/lithos_c/src/manifest.c +++ b/lithos_c/src/manifest.c @@ -315,7 +315,7 @@ void Lth_ResourceMapDestroy(Lth_ResourceMap *rsrc) { if(rsrc == NULL) return; - Lth_HashMapFree(&rsrc->map); + Lth_HashMapDestroy(&rsrc->map); if(rsrc->vecStrng.data) Lth_VectorForEach(char **, rsrc->vecStrng) diff --git a/lithos_c/src/window.c b/lithos_c/src/window.c index 485a44e..56699f4 100644 --- a/lithos_c/src/window.c +++ b/lithos_c/src/window.c @@ -15,30 +15,28 @@ #include -//----------------------------------------------------------------------------| -// Static Functions | -// +// Static Functions ----------------------------------------------------------| // // Lth_WindowDraw // static void Lth_WindowDraw(Lth_Window *ctrl) { - Lth_DrawRectAndClip(ctrl->ctx, ctrl->x, ctrl->y - 8, ctrl->w, 8, 0.35k); - ACS_SetFont(s"SMALLFNT"); - ACS_BeginPrint(); + Lth_DrawRectAndClip(ctrl->ctx, ctrl->x, ctrl->y, ctrl->w, 8, 0.35k); + + Lth_FontRunBegin(); Lth_PrintString(ctrl->title); - Lth_HudMessagePlain(ctrl->ctx->hid.cur--, - ctrl->x + Lth_A_Lef, - ctrl->y - 8 + Lth_A_Top); + Lth_ControlFontRunPlain(ctrl, ctrl->x, ctrl->y); + Lth_ContextClipPop(ctrl->ctx); - Lth_DrawRectAndClip(ctrl->ctx, ctrl->x, ctrl->y, ctrl->w, ctrl->h, 0.5k); + + Lth_DrawRectAndClip(ctrl->ctx, ctrl->x, ctrl->y + 8, ctrl->w, ctrl->h, 0.5k); } // -// Lth_WindowPostDraw +// Lth_WindowDrawPost // -static void Lth_WindowPostDraw(Lth_Window *ctrl) +static void Lth_WindowDrawPost(Lth_Window *ctrl) { Lth_ContextClipPop(ctrl->ctx); } @@ -58,20 +56,19 @@ static void Lth_WindowDestroy(Lth_Window *ctrl) // // Lth_WindowNew // -Lth_Window *Lth_WindowNew(char const *title, int x, int y, int w, int h) +Lth_Window *Lth_WindowNew(Lth_Context *ctx, char const *title, int x, int y, int w, int h) { - Lth_Window *ctrl = calloc(1, sizeof(Lth_Window)); - Lth_assert(ctrl != NULL); + Lth_ControlInit(Lth_Window); - ctrl->w = w; - ctrl->h = h; ctrl->x = x; ctrl->y = y; + ctrl->w = w; + ctrl->h = h; Lth_WindowSetTitle(ctrl, title); - Lth_ControlConnect(ctrl, Lth_SIGDRAW, Lth_Callback(Lth_WindowDraw)); - Lth_ControlConnect(ctrl, Lth_SIGPSTDRAW, Lth_Callback(Lth_WindowPostDraw)); - Lth_ControlConnect(ctrl, Lth_SIGDESTROY, Lth_Callback(Lth_WindowDestroy)); + Lth_ControlConnect(ctrl, Lth_SigDraw, Lth_Callback(Lth_WindowDraw)); + Lth_ControlConnect(ctrl, Lth_SigDrawPst, Lth_Callback(Lth_WindowDrawPost)); + Lth_ControlConnect(ctrl, Lth_SigDestroy, Lth_Callback(Lth_WindowDestroy)); return ctrl; } @@ -81,8 +78,6 @@ Lth_Window *Lth_WindowNew(char const *title, int x, int y, int w, int h) // void Lth_WindowSetTitle(Lth_Window *ctrl, char const *title) { - Lth_assert(ctrl != NULL); - if(title != NULL) ctrl->title = Lth_strdup(title); else diff --git a/lithos_c/src/winman.c b/lithos_c/src/winman.c new file mode 100644 index 0000000..016bb3f --- /dev/null +++ b/lithos_c/src/winman.c @@ -0,0 +1,68 @@ +//----------------------------------------------------------------------------- +// +// Copyright © 2016 Project Golan +// +// See "LICENSE" for more information. +// +//----------------------------------------------------------------------------- +// +// Window management. +// +//----------------------------------------------------------------------------- + +#include "Lth.h" + + +// Static Functions ----------------------------------------------------------| + +// +// WMFont +// +static Lth_Font *WMFont(Lth_Control *ctrl) +{ + Lth_WindowManager *wm = Lth_VirtControl; + + if(wm->font == NULL) + { + char const **name = Lth_ContextResource(wm->ctx, "Base.DefaultFont"); + if(name != NULL) + wm->font = Lth_FontNew(*name); + } + + return wm->font; +} + + +// Extern Functions ----------------------------------------------------------| + +// +// Lth_WMNew +// +Lth_WindowManager *Lth_WMNew(Lth_Context *ctx) +{ + Lth_ControlInit(Lth_WindowManager); + + ctrl->vtable.getFont = WMFont; + + ctrl->lastmap.x = ctrl->lastmap.y = -1; + ctrl->mapspace.x = 24; + ctrl->mapspace.y = 16; + + return ctrl; +} + +// +// Lth_WMMap +// +void Lth_WMMap(Lth_WindowManager *wm, Lth_Window *ctrl) +{ + if(ctrl->x == -1) ctrl->x = wm->lastmap.x += wm->mapspace.x; + else wm->lastmap.x = ctrl->x; + + if(ctrl->y == -1) ctrl->y = wm->lastmap.y += wm->mapspace.y; + else wm->lastmap.y = ctrl->y; + + Lth_ControlAttachTail(wm, ctrl); +} + +// EOF diff --git a/lithos_fs/fonts/SmallFont.lthm b/lithos_fs/fonts/SmallFont.lthm new file mode 100644 index 0000000..517774a --- /dev/null +++ b/lithos_fs/fonts/SmallFont.lthm @@ -0,0 +1,119 @@ +//----------------------------------------------------------------------------- +// +// Copyright © 2016 Project Golan +// +// See "LICENSE" for more information. +// +//----------------------------------------------------------------------------- +// +// Default small font. +// +//----------------------------------------------------------------------------- + +[Font] + +// +// Base +// +// Base font for ASCII glyphs. +// If not supplied, all glyphs will be treated as Unicode. +// +Base = "SMALLFNT" + +// +// Case +// +// Case-sensitivity for font. +// If not supplied, defaults to Both +// +// Both +// Both upper and lower case supported. +// +// UpperOnly +// Any lower case characters printed will be converted to upper-case. +// +// LowerOnly +// Any upper case characters printed will be converted to lower-case. +// +Case = "UpperOnly" + +// +// Glyphs +// +// A list of all glyphs available in this font. +// +Glyphs = "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_" + +// +// Height +// +// Required. +// +Height = 8 + +[Font.GlyphData] +"!_w"=4 +"\"_w"=7 +"#_w"=7 +"$_w"=7 +"%_w"=9 +"&_w"=8 +"'_w"=4 +"(_w"=7 +")_w"=7 +"*_w"=7 +"+_w"=5 +",_w"=4 +"-_w"=6 +"._w"=4 +"/_w"=7 +"0_w"=8 +"1_w"=5 +"2_w"=8 +"3_w"=8 +"4_w"=7 +"5_w"=7 +"6_w"=8 +"7_w"=8 +"8_w"=8 +"9_w"=8 +":_w"=4 +";_w"=4 +"<_w"=5 +"=_w"=5 +">_w"=5 +"?_w"=8 +"@_w"=9 +"A_w"=8 +"B_w"=8 +"C_w"=8 +"D_w"=8 +"E_w"=8 +"F_w"=8 +"G_w"=8 +"H_w"=8 +"I_w"=4 +"J_w"=8 +"K_w"=8 +"L_w"=8 +"M_w"=9 +"N_w"=8 +"O_w"=8 +"P_w"=8 +"Q_w"=8 +"R_w"=8 +"S_w"=7 +"T_w"=8 +"U_w"=8 +"V_w"=7 +"W_w"=9 +"X_w"=9 +"Y_w"=8 +"Z_w"=7 +"[_w"=5 +"\_w"=7 +"]_w"=5 +"^_w"=7 +"__w"=8 + +// EOF diff --git a/lithos_fs/fonts/SmallFontJP.lthm b/lithos_fs/fonts/SmallFontJP.lthm new file mode 100644 index 0000000..80cdb3f --- /dev/null +++ b/lithos_fs/fonts/SmallFontJP.lthm @@ -0,0 +1,274 @@ +//----------------------------------------------------------------------------- +// +// Copyright © 2016 Project Golan +// +// See "LICENSE" for more information. +// +//----------------------------------------------------------------------------- +// +// Default small font, with Japanese Katakana glyphs made by Toooooasty. +// +//----------------------------------------------------------------------------- + +[Font] + +// +// Base +// +// Base font for ASCII glyphs. +// If not supplied, all glyphs will be treated as Unicode. +// +Base = "SMALLFNT" + +// +// Case +// +// Case-sensitivity for font. +// If not supplied, defaults to Both +// +// Both +// Both upper and lower case supported. +// +// UpperOnly +// Any lower case characters printed will be converted to upper-case. +// +// LowerOnly +// Any upper case characters printed will be converted to lower-case. +// +Case = "UpperOnly" + +// +// ExtraDir +// +// Directory for Unicode glyphs. +// If not supplied, no Unicode glyphs will be loaded. +// +ExtraDir = "fonts/SmallFont" + +// +// Suffix +// +// Filename suffix for Unicode glyphs. +// If not supplied, defaults to ".png". +// +Suffix = ".png" + +// +// Type +// +// Filename suffix type for Unicode glyphs. +// If not supplied, defaults to Character. +// +// Character +// Takes the glyph as the suffix. +// Example: た = fonts/SmallFont/STCFNた.png +// +// Codepoint +// Takes the glyph's codepoint as the suffix. +// Example: た = fonts/SmallFont/STCFN305F.png +// +// Digit +// Takes the glyph's base-10 codepoint as the suffix. +// Example: た = fonts/SmallFont/STCFN12383.png +// +Type = "Character" + +// +// Glyphs +// +// A list of all glyphs available in this font. +// +Glyphs = "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_" + "ンえョのコドトにイハシォナウッは)ツどてリた" + "カルなゥヒマらサ、ミタエオモれほヌきメホキじテ" + "るク♥ュィぬセ。ずノニヨユへァ(ーが・ャラを" + "ヘせヤレネりワロソヲもェスチむフひアケ" + "〜ぞム世今夢奥山常我散日有浅為色見越酔ɢᴜ" + +// +// SpaceWidth +// +// If not supplied, defaults to 4. +// +SpaceWidth = 4 + +// +// Height +// +// Required. +// +Height = 8 + +[Font.GlyphData] +"!_w"=4 +"\"_w"=7 +"#_w"=7 +"$_w"=7 +"%_w"=9 +"&_w"=8 +"'_w"=4 +"(_w"=7 +")_w"=7 +"*_w"=7 +"+_w"=5 +",_w"=4 +"-_w"=6 +"._w"=4 +"/_w"=7 +"0_w"=8 +"1_w"=5 +"2_w"=8 +"3_w"=8 +"4_w"=7 +"5_w"=7 +"6_w"=8 +"7_w"=8 +"8_w"=8 +"9_w"=8 +":_w"=4 +";_w"=4 +"<_w"=5 +"=_w"=5 +">_w"=5 +"?_w"=8 +"@_w"=9 +"A_w"=8 +"B_w"=8 +"C_w"=8 +"D_w"=8 +"E_w"=8 +"F_w"=8 +"G_w"=8 +"H_w"=8 +"I_w"=4 +"J_w"=8 +"K_w"=8 +"L_w"=8 +"M_w"=9 +"N_w"=8 +"O_w"=8 +"P_w"=8 +"Q_w"=8 +"R_w"=8 +"S_w"=7 +"T_w"=8 +"U_w"=8 +"V_w"=7 +"W_w"=9 +"X_w"=9 +"Y_w"=8 +"Z_w"=7 +"[_w"=5 +"\_w"=7 +"]_w"=5 +"^_w"=7 +"__w"=8 +"ン_w"=8 +"え_w"=32;"え_h"=32;"え_s"=-1 +"ョ_w"=8 +"の_w"=32;"の_h"=32;"の_s"=-1 +"コ_w"=8 +"ド_w"=8 +"ト_w"=8 +"に_w"=32;"に_h"=32;"に_s"=-1 +"イ_w"=8 +"ハ_w"=8 +"シ_w"=8 +"ォ_w"=8 +"ナ_w"=8 +"ウ_w"=8 +"ッ_w"=8 +"は_w"=32;"は_h"=32;"は_s"=-1 +")_w"=8 +"ツ_w"=8 +"ど_w"=32;"ど_h"=32;"ど_s"=-1 +"て_w"=32;"て_h"=32;"て_s"=-1 +"リ_w"=8 +"た_w"=32;"た_h"=32;"た_s"=-1 +"カ_w"=8 +"ル_w"=8 +"な_w"=32;"な_h"=32;"な_s"=-1 +"ゥ_w"=8 +"ヒ_w"=8 +"マ_w"=8 +"ら_w"=32;"ら_h"=32;"ら_s"=-1 +"サ_w"=8 +"、_w"=8 +"ミ_w"=8 +"タ_w"=8 +"エ_w"=8 +"オ_w"=8 +"モ_w"=8 +"れ_w"=32;"れ_h"=32;"れ_s"=-1 +"ほ_w"=32;"ほ_h"=32;"ほ_s"=-1 +"ヌ_w"=8 +"き_w"=32;"き_h"=32;"き_s"=-1 +"メ_w"=8 +"ホ_w"=8 +"キ_w"=8 +"じ_w"=32;"じ_h"=32;"じ_s"=-1 +"テ_w"=8 +"る_w"=32;"る_h"=32;"る_s"=-1 +"ク_w"=8 +"♥_w"=8 +"ュ_w"=8 +"ィ_w"=8 +"ぬ_w"=32;"ぬ_h"=32;"ぬ_s"=-1 +"セ_w"=8 +"。_w"=8 +"ず_w"=32;"ず_h"=32;"ず_s"=-1 +"ノ_w"=8 +"ニ_w"=8 +"ヨ_w"=8 +"ユ_w"=8 +"へ_w"=32;"へ_h"=32;"へ_s"=-1 +"ァ_w"=8 +"(_w"=8 +"ー_w"=8 +"が_w"=32;"が_h"=32;"が_s"=-1 +"・_w"=32;"・_h"=32;"・_s"=-1 +"ャ_w"=8 +"ラ_w"=8 +"を_w"=32;"を_h"=32;"を_s"=-1 +"ヘ_w"=8 +"せ_w"=32;"せ_h"=32;"せ_s"=-1 +"ヤ_w"=8 +"レ_w"=8 +"ネ_w"=8 +"り_w"=32;"り_h"=32;"り_s"=-1 +"ワ_w"=8 +"ロ_w"=8 +"ソ_w"=8 +"ヲ_w"=8 +"も_w"=32;"も_h"=32;"も_s"=-1 +"ェ_w"=8 +"ス_w"=8 +"チ_w"=8 +"む_w"=32;"む_h"=32;"む_s"=-1 +"フ_w"=8 +"ひ_w"=32;"ひ_h"=32;"ひ_s"=-1 +"ア_w"=8 +"ケ_w"=8 +"〜_w"=8 +"ぞ_w"=32;"ぞ_h"=32;"ぞ_s"=-1 +"ム_w"=8 +"世_w"=32;"世_h"=32;"世_s"=-1 +"今_w"=32;"今_h"=32;"今_s"=-1 +"夢_w"=32;"夢_h"=32;"夢_s"=-1 +"奥_w"=32;"奥_h"=32;"奥_s"=-1 +"山_w"=32;"山_h"=32;"山_s"=-1 +"常_w"=32;"常_h"=32;"常_s"=-1 +"我_w"=32;"我_h"=32;"我_s"=-1 +"散_w"=32;"散_h"=32;"散_s"=-1 +"日_w"=32;"日_h"=32;"日_s"=-1 +"有_w"=32;"有_h"=32;"有_s"=-1 +"浅_w"=32;"浅_h"=32;"浅_s"=-1 +"為_w"=32;"為_h"=32;"為_s"=-1 +"色_w"=32;"色_h"=32;"色_s"=-1 +"見_w"=32;"見_h"=32;"見_s"=-1 +"越_w"=32;"越_h"=32;"越_s"=-1 +"酔_w"=32;"酔_h"=32;"酔_s"=-1 +"ɢ_w"=32;"ɢ_h"=32;"ɢ_s"=-1 +"ᴜ_w"=43;"ᴜ_h"=28;"ᴜ_s"=-1 + +// EOF diff --git a/lithos_gfx/ReplacementCharacter.png b/lithos_gfx/ReplacementCharacter.png new file mode 100644 index 0000000..a8753fa Binary files /dev/null and b/lithos_gfx/ReplacementCharacter.png differ