- Timestamp:
- Apr 29, 2024, 7:05:34 PM (2 months ago)
- Branches:
- main
- Children:
- d6dc8dd
- Parents:
- 2317cb2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main.cpp
r2317cb2 r9202152 6 6 7 7 #include "HyperTextView.h" 8 #include "IdentityWindow.h" 8 9 9 10 #include <Application.h> … … 265 266 uint8_t gSavePC; 266 267 uint8_t gGameStatus; 268 bool gGender; 269 BString gFirstName; 270 BString gLastName; 267 271 268 272 uint32_t gLastRunScript; … … 622 626 { 623 627 // @ Gender mark (print an e if the player identifies as female) 624 // TODO we don't have a way to configure player gender yet625 decoded += 'e';628 if (gGender) 629 decoded += 'e'; 626 630 cursor++; 627 631 break; … … 665 669 int icursor = cursor; 666 670 // {%f3|%m2~%m3} 671 // {%c3|%m2|%m3|...} 672 // {male|female} 667 673 cursor++; 668 if (message[cursor] != '%' || message[cursor + 1] != 'f') { 669 fprintf(stderr, "Unknwown message conditional\n"); 670 return 1; 671 } 672 673 cursor += 2; 674 if (message[cursor] == '%') { 675 if ( message[cursor + 1] == 'f') { 676 cursor += 2; 677 return HandlePercentFConditional(message, cursor) + 3; 678 } else { 679 fprintf(stderr, "Unknwown message conditional\n"); 680 return 2; 681 } 682 } 683 684 int start, end; 685 686 if (gGender) { 687 while(message[cursor] != '|') 688 cursor++; 689 cursor++; 690 start = cursor; 691 while(message[cursor] != '}') 692 cursor++; 693 end = cursor; 694 cursor++; 695 } else { 696 start = cursor; 697 while(message[cursor] != '|') 698 cursor++; 699 end = cursor; 700 cursor++; 701 while(message[cursor] != '}') 702 cursor++; 703 cursor++; 704 } 705 706 std::string extracted = message.substr(start, end - start); 707 fMainText->Insert(extracted.c_str()); 708 709 return cursor - icursor; 710 } 711 712 int HandlePercentFConditional(const std::string& message, int cursor) 713 { 714 int icursor = cursor; 674 715 675 716 int flagToCheck = ParseInt(message, cursor); … … 718 759 i++; 719 760 } 761 762 // TODO links can contain escape sequences (for example @) 720 763 721 764 while (message[cursor + i] != ']') { … … 744 787 return 3; 745 788 } else if (message[cursor] == 'p') { 746 // Should show the player first name, not configurable yet 747 decoded += "PRENOM"; 789 decoded += gFirstName; 790 return 2; 791 } else if (message[cursor] == 'n') { 792 decoded += gLastName; 748 793 return 2; 749 794 } else { … … 799 844 void ReadyToRun() override 800 845 { 846 BWindow* identity = new IdentityWindow(); 847 identity->Show(); 848 identity->CenterOnScreen(); 849 801 850 // TODO check if we have a game loaded 802 851 fMainWindow = new GameWindow(); … … 806 855 fDebugWindow = new DebugWindow(); 807 856 808 fMainWindow->Show();809 fMainWindow->CenterOnScreen();810 857 811 858 // TODO: only if asked from the command line … … 816 863 fDebugWindow->Update(); 817 864 818 bool runNextLine = true;819 int line = 0;820 while (runNextLine && (line < gRooms[0].fScripts.size())) {821 gSavePC = 0;822 runNextLine = RunScriptLine(gRooms[0].fScripts[line]);823 gLastRunScript = line;824 line++;825 }826 fMainWindow->SetMainText(gRooms[gCurrentRoom].fMessages[gCurrentScreen - 1]);827 fDebugWindow->Update();828 865 } 829 866 830 867 void MessageReceived(BMessage* message) override 831 868 { 832 if (message->what < 256) { 869 if (message->what == 'STRT') { 870 fMainWindow->Show(); 871 fMainWindow->CenterOnScreen(); 872 873 bool runNextLine = true; 874 int line = 0; 875 while (runNextLine && (line < gRooms[0].fScripts.size())) { 876 gSavePC = 0; 877 runNextLine = RunScriptLine(gRooms[0].fScripts[line]); 878 gLastRunScript = line; 879 line++; 880 } 881 fMainWindow->SetMainText(gRooms[gCurrentRoom].fMessages[gCurrentScreen - 1]); 882 fDebugWindow->Update(); 883 } else if (message->what < 256) { 833 884 gTrigger = message->what; 834 885
Note:
See TracChangeset
for help on using the changeset viewer.