Klappt leider immer noch nicht. "Fahne" erscheint zwar wie gehabt, aber immer noch ohne Text.
Ich hielt den kompletten Code (selbst für diese Prozedure) für etwas zu umfangreich, zumal da weitere Prozeduren drin sind. Ausführbar ist ohnehin nur das gesamte Programm unter der Voraussetzung, daß weitere Dateien vorhanden sind. Irgendwo, meinte ich, muß ich da schon etwas herausschneiden. Aber hier zumindest die komplette Prozedur incl. SetGadgetState:
Code: Alles auswählen
Procedure bild(invers, cur_path$,map_path$,map_h$,ed_m02$,einheit$)
imagenr_memory$ = ed_m02_testen(map_h$,ed_m02$)
imagenr = Val(StringField(imagenr_memory$,1,"/"))
*memoryID = Val(StringField(imagenr_memory$,2,"/"))
B_Breite_hoehe$ = desktop()
B_breite = Val(StringField(B_Breite_Hoehe$,1,"/"))
B_hoehe = Val(StringField(B_Breite_Hoehe$,2,"/"))
window = OpenWindow(#PB_Any, 50, 50, B_breite, B_hoehe, "",#PB_Window_SystemMenu |#PB_Window_SizeGadget | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget)
windowID = WindowID(window)
window1 = OpenWindow(#PB_Any,50 + B_breite - 125,50 + 35,102,47," ",#PB_Window_BorderLess | #PB_Window_NoGadgets)
window1ID = WindowID(window1)
StickyWindow(window1,1)
UseGadgetList(window1ID)
text_gad = TextGadget(#PB_Any,5,5,100,50,"Pos:")
text_gad1 = TextGadget(#PB_Any,5,25,100,50,"")
Font = LoadFont(#PB_Any, "Verdana" , 10, #PB_Font_Bold)
SetGadgetFont(text_gad, FontID(Font))
SetGadgetFont(text_gad1,FontID(font))
UseGadgetList(windowID)
Ergebnis = CountString(map_path$, "\")
map_folder$ =StringField(map_path$,ergebnis,"\")
over_map$ = GetFilePart(ed_m02$)
height_map$ = GetFilePart(map_h$)
SetWindowTitle(window,"Map: " + map_folder$ + " Overview map: " + over_map$ + " Heightmap: " + height_map$)
breite = PeekW(*memoryID + 12)
hoehe = PeekW(*memoryID + 14)
scroll = ScrollAreaGadget(#PB_Any, 0, 0, B_breite, B_hoehe, breite, hoehe,200)
img = ImageGadget(#PB_Any, 0, 0, Breite, Hoehe,imageNr)
SetCurrentDirectory(cur_path$)
load_kompass = LoadImage(#PB_Any,"Kompass3.png")
imageNr1 = ImageID(load_kompass)
kompass = ImageGadget(#PB_Any,50,200,300,300,imageNr1)
load_fahne= LoadImage(#PB_Any,"Fahne.png")
imageNr2 = ImageID(load_fahne)
fahne = ImageGadget(#PB_Any,50+130,200+120,152,86,imageNr2)
SetCurrentDirectory(map_path$)
;CloseGadgetList()
map_h = ReadFile(#PB_Any,map_h$)
FileSeek(map_h,12)
breite_map_h = ReadWord(map_h)
hoehe_map_h = ReadWord(map_h)
v = test_breite(breite,breite_map_h)
If v = 0
close_windows(window,window1,scroll,img,text_gad,text_gad1,font,*memoryID)
ProcedureReturn(0)
EndIf
FileSeek(map_h,18)
Dim pos(breite_map_h,hoehe_map_h)
If invers
For y = 1 To hoehe_map_h
For x = 1 To breite_map_h
pos(x,hoehe_map_h-y) = ReadCharacter(map_h)
Next
Next
Else
For y = 1 To hoehe_map_h
For x = 1 To breite_map_h
pos(x,y) = ReadCharacter(map_h)
Next
Next
EndIf
CloseFile(map_h)
;Debug "Verhältnis: " + Str(v)
Repeat
;SetActiveWindow(window)
event = WaitWindowEvent()
If EventWindow() = window
If event = #PB_Event_Gadget
If EventGadget() = scroll
x_scroll = GetGadgetAttribute(scroll, #PB_ScrollArea_X)
y_scroll = GetGadgetAttribute(scroll, #PB_ScrollArea_Y)
ElseIf EventGadget() = img
If EventType() = #PB_EventType_LeftClick
Debug "Links"
;SetActiveGadget(kompass)
DragImage(ImageID(load_kompass))
maus_x = WindowMouseX(window) + x_scroll - 150
maus_y = WindowMouseY(window) + y_scroll -150
kompass_x = Round(maus_x/v,#PB_Round_Nearest)
kompass_y = Round(maus_y/v,#PB_Round_Nearest)
HideGadget(kompass,1)
HideGadget(fahne,1)
ResizeGadget(kompass, maus_x, maus_y, #PB_Ignore, #PB_Ignore)
ResizeGadget(fahne,maus_x+130,maus_y+120,#PB_Ignore, #PB_Ignore)
HideGadget(kompass,0)
HideGadget(fahne,0)
ElseIf EventType() = #PB_EventType_RightClick
Debug "Rechts"
maus_x = WindowMouseX(window) + x_scroll - 150
maus_y = WindowMouseY(window) + y_scroll -150
fahne_x = Round(maus_x/v,#PB_Round_Nearest)
fahne_y = Round(maus_y/v,#PB_Round_Nearest)
HideGadget(fahne,1)
ResizeGadget(fahne,maus_x+137,maus_y+73,#PB_Ignore, #PB_Ignore)
HideGadget(fahne,0)
distanz = distanz(kompass_x,kompass_y,fahne_x,fahne_y,v)
distanz$ = StrF(distanz/1000,3)
;--------------------------------------
Font = LoadFont(#PB_Any, "Verdana" ,12.5, #PB_Font_Bold)
ergebnis = StartDrawing(ImageOutput(load_fahne))
DrawingMode(#PB_2DDrawing_Transparent)
Debug "StartDrawing" + Str(ergebnis)
DrawingFont(FontID(font))
Ergebnis = DrawText(maus_x+141 + 33,maus_y+80,distanz$ + " Km",$1324FF); [, HintergrundFarbe]])
Debug "DrawText: " + Str(ergebnis)
StopDrawing()
SetGadgetState(fahne,imageNr2)
EndIf
EndIf
:-----------------------------------------
ElseIf event = #PB_Event_MoveWindow
Debug "move"
x_win = WindowX(Window)
y_win = WindowY(window)
ResizeWindow(window1, x_win+B_breite-125,y_win+35,102,47)
ElseIf event = #PB_Event_SizeWindow
B_breite = WindowWidth(window)
B_hoehe = WindowHeight(window)
x_win = WindowX(Window)
y_win = WindowY(window)
ResizeGadget(scroll, 0,0, B_Breite, B_Hoehe)
ResizeWindow(window1, x_win+B_breite-125,y_win+35,102,47)
distanz = distanz(kompass_x,kompass_y,fahne_y,fahne_x,v)
EndIf
EndIf
maus_x = WindowMouseX(window) + x_scroll
maus_y = WindowMouseY(window) + y_scroll
If maus_x > 0 And maus_x < breite + 1
If maus_y > 0 And maus_y < hoehe + 1
If v > 1
maus_x = Round(maus_x/v,#PB_Round_Nearest)
maus_y = Round(maus_y/v,#PB_Round_Nearest)
EndIf
height = height(pos(maus_x,maus_y),window1ID,text_gad1,einheit$)
position(maus_x,hoehe_map_h-(maus_y),text_gad,text_gad1,hoehe_map_h)
EndIf
EndIf
SetGadgetText(text_gad1,Str(height) + " " + einheit$)
Until event = #PB_Event_CloseWindow
close_windows(window,window1,scroll,img,text_gad,text_gad1,font,*memoryID)
;CloseScreen()
Dim pos(0,0)
EndProcedure