Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
//--------------------------------------------------------------------------- #include <vcl\vcl.h> #pragma hdrstop #include "Viewer.h" //--------------------------------------------------------------------------- #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::FormCreate(TObject *Sender) { FILE* pf; TImage* Image[10]; char command[256], comment[256]; int ImageNum = 0, Position = 8, LinePitch = 10; pf = fopen("Test.kds", "r"); for(int i = 0; i < 10; i++) Image[i] = new TImage(this); while(!feof(pf)) { fscanf(pf, "%s", command); if(strcmp(command, "//") == 0) { fgets(comment, 256, pf); } else if(strcmp(command, "LinePitch:") == 0) { fscanf(pf, "%d", &LinePitch); } else if(strcmp(command, "Picture:") == 0) { fscanf(pf, "%s", command); Image[ImageNum]->Parent = this; Image[ImageNum]->Stretch = false; Image[ImageNum]->AutoSize = true; Image[ImageNum]->Left = 8; Image[ImageNum]->Top = Position; Image[ImageNum]->Picture->LoadFromFile(command); Position += Image[ImageNum]->Height + LinePitch; ImageNum++; } else if(strcmp(command, "Font:") == 0) { fscanf(pf, "%s", command); Canvas->Font->Size = StrToInt(command); fscanf(pf, "%s", command); if(strcmp(command, "AQUA") == 0) Canvas->Font->Color = clAqua; else if(strcmp(command, "BLACK") == 0) Canvas->Font->Color = clBlack; else if(strcmp(command, "BLUE") == 0) Canvas->Font->Color = clBlue; else if(strcmp(command, "DKGRAY") == 0) Canvas->Font->Color = clDkGray; else if(strcmp(command, "FUCHSIA") == 0) Canvas->Font->Color = clFuchsia; else if(strcmp(command, "GRAY") == 0) Canvas->Font->Color = clGray; else if(strcmp(command, "GREEN") == 0) Canvas->Font->Color = clGreen; else if(strcmp(command, "LIME") == 0) Canvas->Font->Color = clLime; else if(strcmp(command, "LTGRAY") == 0) Canvas->Font->Color = clLtGray; else if(strcmp(command, "MAROON") == 0) Canvas->Font->Color = clMaroon; else if(strcmp(command, "NAVY") == 0) Canvas->Font->Color = clNavy; else if(strcmp(command, "OLIVE") == 0) Canvas->Font->Color = clOlive; else if(strcmp(command, "PURPLE") == 0) Canvas->Font->Color = clPurple; else if(strcmp(command, "RED") == 0) Canvas->Font->Color = clRed; else if(strcmp(command, "SILVER") == 0) Canvas->Font->Color = clSilver; else if(strcmp(command, "TEAL") == 0) Canvas->Font->Color = clTeal; else if(strcmp(command, "WHITE") == 0) Canvas->Font->Color = clWhite; else if(strcmp(command, "YELLOW") == 0) Canvas->Font->Color = clYellow; fscanf(pf, "%s", command); if(strcmp(command, "Arial_Black") == 0) Canvas->Font->Name = "Arial Black"; else if(strcmp(command, "ChordFont_4.0") == 0) Canvas->Font->Name = "ChordFont 4.0"; else if(strcmp(command, "Comic_Sans_MS") == 0) Canvas->Font->Name = "Comic Sans MS"; else if(strcmp(command, "Courier_New") == 0) Canvas->Font->Name = "Courier New"; else if(strcmp(command, "Estrangelo_Edessa") == 0) Canvas->Font->Name = "Estrangelo Edessa"; else if(strcmp(command, "Franklin_Gothic_Medium") == 0) Canvas->Font->Name = "Franklin Gothic Medium"; else if(strcmp(command, "Gill_Sans_MT") == 0) Canvas->Font->Name = "Gill Sans MT"; else if(strcmp(command, "Lucida_Console") == 0) Canvas->Font->Name = "Lucida Console"; else if(strcmp(command, "Lucida_Sans_Unicode") == 0) Canvas->Font->Name = "Lucida Sans Unicode"; else if(strcmp(command, "Microsoft_Sans_Serif") == 0) Canvas->Font->Name = "Microsoft Sans Serif"; else if(strcmp(command, "MS_Sans_Serif") == 0) Canvas->Font->Name = "MS Sans Serif"; else if(strcmp(command, "MS_Serif") == 0) Canvas->Font->Name = "MS Serif"; else if(strcmp(command, "MV_Boli") == 0) Canvas->Font->Name = "MV Boli"; else if(strcmp(command, "Palatino_Linotype") == 0) Canvas->Font->Name = "Palatino Linotype"; else if(strcmp(command, "Score_Font_4.0") == 0) Canvas->Font->Name = "Score Font 4.0"; else if(strcmp(command, "Steinberg_Chord_Symbols_Fonts") == 0) Canvas->Font->Name = "Steinberg Chord Symbols Fonts"; else if(strcmp(command, "Steinberg_Notation") == 0) Canvas->Font->Name = "Steinberg Notation"; else if(strcmp(command, "Times_New_Roman") == 0) Canvas->Font->Name = "Times New Roman"; else if(strcmp(command, "Trebuchet_MS") == 0) Canvas->Font->Name = "Trebuchet MS"; else Canvas->Font->Name = command; fgets(command, 256, pf); for(int i = 0; i < StrLen(command); i++) { command[i] = command[i+1]; } Canvas->TextOut(8, Position, command); Position += Canvas->TextHeight(command) + LinePitch; } } fclose(pf); } //--------------------------------------------------------------------------- |
C-/C++-Quelltext |
|
1 2 |
else if(strcmp(command, "Microsoft_Sans_Serif") == 0) Canvas->Font->Name = "Microsoft Sans Serif"; |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
//--------------------------------------------------------------------------- #include <vcl\vcl.h> #pragma hdrstop #include "Viewer.h" //--------------------------------------------------------------------------- #pragma resource "*.dfm" TForm1 *Form1; #include <map> using namespace std; map<const char *, TColor, less<const char *> > color_name_map; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::FormCreate(TObject *Sender) { FILE* pf; TImage* Image[10]; char command[256], comment[256], help[256];; int ImageNum = 0, Position = 8, LinePitch = 10; pf = fopen("Test.kds", "r"); for(int i = 0; i < 10; i++) Image[i] = new TImage(this); color_name_map["AQUA"] = clAqua; color_name_map["BLACK"] = clBlack; color_name_map["BLUE"] = clBlue; color_name_map["DKGRAY"] = clDkGray; color_name_map["FUCHSIA"] = clFuchsia; color_name_map["GRAY"] = clGray; color_name_map["GREEN"] = clGreen; color_name_map["LIME"] = clLime; color_name_map["LTGRAY"] = clLtGray; color_name_map["MAROON"] = clMaroon; color_name_map["NAVY"] = clNavy; color_name_map["OLIVE"] = clOlive; color_name_map["PURPLE"] = clPurple; color_name_map["RED"] = clRed; color_name_map["SILVER"] = clSilver; color_name_map["TEAL"] = clTeal; color_name_map["WHITE"] = clWhite; color_name_map["YELLOW"] = clYellow; while(!feof(pf)) { fscanf(pf, "%s", command); if(strcmp(command, "//") == 0) { fgets(comment, 256, pf); } else if(strcmp(command, "LinePitch:") == 0) { fscanf(pf, "%d", &LinePitch); } else if(strcmp(command, "Picture:") == 0) { fscanf(pf, "%s", command); Image[ImageNum]->Parent = this; Image[ImageNum]->Stretch = false; Image[ImageNum]->AutoSize = true; Image[ImageNum]->Left = 8; Image[ImageNum]->Top = Position; Image[ImageNum]->Picture->LoadFromFile(command); Position += Image[ImageNum]->Height + LinePitch; ImageNum++; } else if(strcmp(command, "Font:") == 0) { fscanf(pf, "%s", command); Canvas->Font->Size = StrToInt(command); fscanf(pf, "%s", command); Canvas->Font->Color = color_name_map[command]; fscanf(pf, "%s", command); strcpy(help, command); for(char* c = help; *c != 0; c++) { if(*c == '_') { *c = ' '; } } Canvas->Font->Name = help; fgets(command, 256, pf); for(int i = 0; i < StrLen(command); i++) { command[i] = command[i+1]; } Canvas->TextOut(8, Position, command); Position += Canvas->TextHeight(command) + LinePitch; } } fclose(pf); } //--------------------------------------------------------------------------- |
Werbeanzeige