also ich poste hier einfach mal den code wie gesagt da das projekt nach der GC letztes jahr nicht weitergeführt wurde ist die GUI auch nicht komplet aber so als Denkanstoss:
Der Code zum erzeugen eines Fenster`s usw:
BlitzBasic: [AUSKLAPPEN] [EINKLAPPEN] window = create_window(100,100,400,200) local_button = create_button(window,20,-150,40,20,\"media\gfx\HUD/GUI_HUD_BTN.bmp\") zone_button = create_button(window,20,-120,40,20,\"media\gfx\HUD/GUI_HUD_BTN.bmp\") privat_button = create_button(window,20,-90,40,20,\"media\gfx\HUD/GUI_HUD_BTN.bmp\") clan_button = create_button(window,20,-60,40,20,\"media\gfx\HUD/GUI_HUD_BTN.bmp\") Local_label = create_label(window,70,-150,100,20,\"Local\",91,123,142) zone_label = create_label(window,70,-120,100,20,\"Zone\",91,123,142) privat_label = create_label(window,70,-90,100,20,\"Privat\",91,123,142) privat_label = create_label(window,70,-60,100,20,\"Privat\",91,123,142) create_label(window,150,192,100,20,\"Hypercom\",91,123,142) inv_imag_5 = create_imagebox(window3,160,-60,120,100,\"media\gfx\inv\free\") inv_imag_6 = create_imagebox(window3,300,-60,120,100,\"media\gfx\inv\free\")
und hier die funktionssammlung
BlitzBasic: [AUSKLAPPEN] [EINKLAPPEN] Function create_window(x_pos,y_pos,x_scal,y_scal) f.fenster = New fenster f\sprite = CreateSprite(camera) EntityFX f\sprite,8 ScaleSprite f\sprite ,x_scal,y_scal EntityAlpha f\sprite,.8 HandleSprite f\sprite,-1,1 PositionEntity f\sprite,((x_pos)*2)-aufx,-((y_pos)*2)+aufy,aufx temp = LoadTexture (\"media\gfx\HUD/GUI_SKILL\",1) EntityTexture f\sprite ,temp EntityBlend f\sprite,1 EntityOrder f\sprite,-1 f\x_scal = x_scal f\x = x_pos f\y = y_pos Return f\sprite End Function
Function create_button(wnd,x_pos,y_pos,x_scal,y_scal,tex$) b.button = New button b\sprite = CreateSprite(wnd) b\tex = LoadAnimTexture (tex,4,40,20,0,2) EntityFX b\sprite,8 b\x=x_pos b\y=y_pos HandleSprite b\sprite,-1,-1 ScaleSprite b\sprite ,x_scal,y_scal MoveEntity b\sprite ,x_pos*2,y_pos*2-(y_scal*2),0 EntityTexture b\sprite,b\tex,0 EntityBlend b\sprite,3 EntityOrder b\sprite,-1 Return b\sprite End Function
Function move_window(x_ver,y_ver,mx,my) For f.fenster = Each fenster If MouseDown(1) Then If (mx>f\x) And (mx<(f\x+f\x_scal))Then If (my>f\y) And (my<(f\y+20)) Then f\x = f\x + x_ver f\y = f\y - y_ver PositionEntity f\sprite ,EntityX(f\sprite)+(x_ver*2),EntityY(f\sprite)+(y_ver*2),EntityZ(f\sprite) EndIf EndIf EndIf Next End Function
Function destoy_GUI() For b.button = Each button FreeEntity b\sprite Delete b Next For f.fenster = Each fenster FreeEntity f\sprite Delete f Next End Function
Function create_label(wnd,x_pos,y_pos,x_scal,y_scal,inhalt$,r,g,b) SetFont Font ClsColor 0,0,0 l.label = New label l\sprite = CreateSprite(wnd) EntityFX l\sprite,8 HandleSprite l\sprite,-1,-1 EntityAlpha l\sprite,.9 ScaleSprite l\sprite ,x_scal,y_scal MoveEntity l\sprite ,x_pos*2,y_pos*2-(y_scal*2),0 temp = CreateTexture(x_scal,y_scal) SetBuffer TextureBuffer(temp) Cls Color 255,255,255 Text 0,0,inhalt SetBuffer BackBuffer() EntityTexture l\sprite,temp EntityBlend l\sprite,3 EntityOrder l\sprite,-1.5 Return l\sprite SetFont Font2 End Function
Function create_imagebox(wnd,x_pos,y_pos,x_scal,y_scal,url$) i.image = New image i\sprite = CreateSprite(wnd) EntityFX i\sprite,8 i\x=x_pos i\y=y_pos HandleSprite i\sprite,-1,-1 ScaleSprite i\sprite ,x_scal,y_scal EntityAlpha i\sprite,.7 MoveEntity i\sprite ,x_pos*2,y_pos*2-(y_scal*2),0 DebugLog(url) i\textur = LoadTexture (url) EntityTexture i\sprite,i\textur EntityOrder i\sprite,-1 Return i\sprite End Function
Function update_label(lbl,sting$,x_scal,y_scal) SetFont Font temp = CreateTexture(x_scal,y_scal) SetBuffer TextureBuffer(temp) Color 255,255,255 Text 0,0,sting SetBuffer BackBuffer() EntityTexture lbl,temp SetFont Font2 End Function
Function create_textbox(wnd,x_pos,y_pos,x_scal,y_scal,String_v$,r,g,b) SetFont Font t.text_box = New text_box t\sprite = CreateSprite(wnd) EntityFX t\sprite,8 HandleSprite t\sprite,-1,-1 ScaleSprite t\sprite ,x_scal,y_scal MoveEntity t\sprite ,x_pos*2,y_pos*2-(y_scal*2),0 temp = CreateTexture(x_scal,y_scal) SetBuffer TextureBuffer(temp) ClsColor 0,0,0 Color 255,255,255 ClsColor 0,0,0 Cls PrintText(String_v,y_scal,x_scal,0,0) SetBuffer BackBuffer() EntityTexture t\sprite,temp EntityBlend t\sprite,3 EntityOrder t\sprite,-2 SaveBuffer(TextureBuffer(temp),\"tempos.bmp\") Return t\sprite SetFont Font2 End Function
Function PrintText(Text$,H#,W#,X#,Y#) Local l = Len(Text) Local Ausgabe$ Local lges = 1 Local SH = StringHeight(Text) Local TH = 0 Local Text2$ = Text Local Zeilen = 0 Local LastString .NewLine For i% = 1 To Len(Text2) If H > Zeilen * SH Then If StringWidth(Mid (Text2,1, i)) > W Then Ausgabe = Mid (Text2,1, i) If Left(Ausgabe,1) = \" \" Then Ausgabe = Mid(Ausgabe,2,Len(Ausgabe)) EndIf Text2 = Mid(Text2,i+1,Len(Text)) Text X,Y+TH,Ausgabe Zeilen = Zeilen + 1 LastString = i Exit Else If StringWidth(Mid (Text2,1, i)) < W Then If Len(Text2) < LastString Then Ausgabe = Mid (Text2,1, Len(Text2)) If Left(Ausgabe,1) = \" \" Then Ausgabe = Mid(Ausgabe,2,Len(Ausgabe)) EndIf Text2 = \"\" Text X,Y+TH,Ausgabe Zeilen = Zeilen + 1 EndIf EndIf EndIf Else Goto TextEnd EndIf Next If Len(text2) > 0 Then TH = TH + SH Goto NewLine End If .TextEnd End Function
Function update_button(mx,my) For b.button = Each button If m_button = 1 Then CameraProject camera,EntityX(b\sprite,1),EntityY(b\sprite,1),EntityZ(b\sprite,1) If (mx > ProjectedX()) And (mx < (ProjectedX()+40)) Then If (my>(ProjectedY()-20)) And (my < ProjectedY()) Then EntityTexture b\sprite,b\tex,1 Return b\sprite EndIf EndIf Else EntityTexture b\sprite,b\tex,0 EndIf Next End Function
Function Edit_input$(x,y,txt$,id) key=GetKey() If key>31 Then txt$=txt$+Chr(key) If KeyHit(181) Then txt$=Left(txt$,Len(txt$)-1):txt$=txt$+\"/\" If KeyHit(83) Then txt$=txt$+\",\" If KeyHit(14) And Len(txt$)>0 Then txt$=Left(txt$,Len(txt$)-1) Return txt$ End Function
Function create_Edit(wnd,x_pos,y_pos,x_scal,y_scal,inhalt$,r,g,b) E.Edit = New Edit e\sprite = CreateSprite(wnd) HandleSprite e\sprite,-1,-1 EntityAlpha e\sprite,.9 ScaleSprite e\sprite ,x_scal,y_scal MoveEntity e\sprite ,x_pos*2,y_pos*2-(y_scal*2),0 e\texture = CreateTexture(x_scal,y_scal) SetBuffer TextureBuffer(e\texture) Color 255,255,255 ClsColor 0,0,0 Cls Text 0,0,inhalt SetBuffer BackBuffer() EntityTexture e\sprite,e\texture EntityBlend e\sprite,3 EntityOrder e\sprite,-2 e\x_scal=x_scal e\y_scal = y_scal e\aktiv = 0 e\inhalt = inhalt SaveBuffer (TextureBuffer(e\texture),\"test.bmp\") Return e\sprite End Function
Function update_edit() For e.edit = Each edit If KeyDown(28) Then e\aktiv = 0 If MouseDown(1) e\aktiv = 0 CameraProject camera,EntityX(e\sprite,1),EntityY(e\sprite,1),EntityZ(e\sprite,1) If (MouseX() > ProjectedX()) And (MouseX() < (ProjectedX()+e\x_scal)) Then If (MouseY()>(ProjectedY()-e\y_scal)) And (MouseY() < ProjectedY()) Then e\aktiv = 1 FlushKeys EndIf EndIf EndIf FreeTexture e\texture If e\aktiv = 1 Then e\inhalt = Edit_input$(10,20,e\inhalt,1) e\texture = write_Edit(e\sprite,Str(e\inhalt),300,40,100,100,100) Else e\texture = write_Edit(e\sprite,Str(e\inhalt),300,40,50,50,50) EndIf Next End Function
Function write_Edit(lbl,sting$,x_scal,y_scal,r,g,b) SetFont Font tex = CreateTexture(x_scal,y_scal) SetBuffer TextureBuffer(tex) Color 255,255,255 ClsColor r,g,b Cls Text 0,0,sting SetBuffer BackBuffer() EntityTexture lbl,tex Return tex SetFont Font2 End Function
Function update_imagebox(img,url$) For i.image = Each image If img = i\sprite Then i\textur = LoadTexture(url) DebugLog(url) EntityTexture i\sprite,i\textur EndIf Next End Function
Function create_quickbar(url$,x_pos,y_pos) q.quickbar = New quickbar q\img = LoadImage(url) q\x = x_pos q\y = y_pos q\item = \"0\" End Function
Function draw_quickbar() For q.quickbar = Each quickbar DrawImage q\img,q\x,q\y Next End Function
Function draw_quickbar_item() temp = 0 For q.quick_bar = Each quick_bar If temp > 9 Then FreeImage q\item Delete q Else DrawImage q\item,953,134+(temp*38) temp = temp + 1 EndIf Next End Function Function use_quick_bar() anz.anz_in_qbar = First anz_in_qbar
akt.akt_qbar = First akt_qbar
If KeyHit(11) Then If anz\anz > -1 Then If akt\akt <> 0 Then akt.akt_qbar = First akt_qbar akt\akt = 0 Else akt\akt = -1 EndIf Else akt\akt = -1 EndIf EndIf
If KeyHit(2) Then If anz\anz > 0 Then If akt\akt <> 1 Then akt.akt_qbar = First akt_qbar akt\akt = 1 Else akt\akt = -1 EndIf Else akt\akt = -1 EndIf EndIf
If KeyHit(3) Then If anz\anz > 1 Then If akt\akt <> 2 Then akt.akt_qbar = First akt_qbar akt\akt = 2 Else akt\akt = -1 EndIf Else akt\akt = -1 EndIf EndIf
If KeyHit(4) Then If anz\anz > 2 Then If akt\akt <> 3 Then akt.akt_qbar = First akt_qbar akt\akt = 3 Else akt\akt = -1 EndIf Else akt\akt = -1 EndIf EndIf
If KeyHit(5) Then If anz\anz > 3 Then If akt\akt <> 4 Then akt.akt_qbar = First akt_qbar akt\akt = 4 Else akt\akt = -1 EndIf Else akt\akt = -1 EndIf EndIf
If KeyHit(6) Then If anz\anz > 4 Then If akt\akt <> 5 Then akt.akt_qbar = First akt_qbar akt\akt = 5 Else akt\akt = -1 EndIf Else akt\akt = -1 EndIf EndIf
If KeyHit(7) Then If anz\anz > 5 Then If akt\akt <> 6 Then akt.akt_qbar = First akt_qbar akt\akt = 6 Else akt\akt = -1 EndIf Else akt\akt = -1 EndIf EndIf
If KeyHit(8) Then If anz\anz > 6 Then If akt\akt <> 7 Then akt.akt_qbar = First akt_qbar akt\akt = 7 Else akt\akt = -1 EndIf Else akt\akt = -1 EndIf EndIf
If KeyHit(9) Then If anz\anz > 7 Then If akt\akt <> 8 Then akt.akt_qbar = First akt_qbar akt\akt = 8 Else akt\akt = -1 EndIf Else akt\akt = -1 EndIf EndIf
If KeyHit(10) Then If anz\anz > 8 Then If akt\akt <> 9 Then akt.akt_qbar = First akt_qbar akt\akt = 9 Else akt\akt = -1 EndIf Else akt\akt = -1 EndIf EndIf
End Function
Function show_qbar_item() akt.akt_qbar = First akt_qbar temp = 0 For q.quick_bar = Each quick_bar temp = temp + 1 If temp = akt\akt Then If akt\model <> 0 Then FreeEntity akt\model akt\model = LoadMesh(\"media\gfx\weapon\\" + q\url + \".3DS\",camera) EntityColor akt\model,150,150,150 If q\url = \"Pistol2\" Then MoveEntity akt\model,.08,-.02,.14 ScaleMesh akt\model,.1,.1,.1 TurnEntity akt\model,0,180,0 EndIf If q\url = \"Pistol1\" Then MoveEntity akt\model,.08,-.02,.14 ScaleMesh akt\model,.0035,.0035,.0035 TurnEntity akt\model,0,90,0 EndIf EndIf Next If akt\akt = -1 Then If akt\model <> 0 Then FreeEntity akt\model akt\model = 0 EndIf EndIf
End Function
[/syntax]
|