Code:
unit cc_guimain;
{$mode objfpc}{$H+}
{$i jui.inc}
{$i pin.inc}
{$i cc.inc}
interface
uses
Classes, sysutils, sdl, u_gl,
j2d, j2d_poly, j2d_polygroup, j2d_tspline,
jui_const, jui_log, jui_screen, jui_textureman, jui_font,
jui_mouse, jui_cursor,
jui_global, jui_message, jui_messenger, jui_keyboard,
jui_lockable, jui_theme, jui_element, jui_window,
jui_windowman, jui_widget, jui_basetypes, jui_titlebar, jui_button,
jui_colourwheel, jui_editbox, jui_listview, jui_scrollbar,
pin_log, pin_lockable, pin_message, pin_messenger, pin_tcp,
cc_global, cc_gamestate;
type
TCCGUIMain = class
private
WindowMan : TJUIWindowMan;
public
Window : TJUIWindow;
TitleBar : TJUITitleBar;
StartServerButton : TJUIButton;
StartClientButton : TJUIButton;
EditBox : TJUIEditBox;
ListView : TJUIListView;
constructor create(AWindowMan : TJUIWindowMan);
destructor destroy;override;
procedure StartServerClick(ButtonMessage : TMsgMouseButton);
procedure StartClientClick(ButtonMessage : TMsgMouseButton);
end;
implementation
constructor TCCGUIMain.create(AWindowMan : TJUIWindowMan);
var
TempButton : TJUIButton;
begin
WindowMan := AWindowMan;
Window := WindowMan.CreateWindow;
Window.LocalRect := J2DRect(10,10,360,360);
Window.Caption := 'GUIMain - Testing Widgets';
TJUIWidget(TitleBar) := Window.CreateWidget(TJUITitleBar);
TitleBar.LocalRect := J2DRect(0,0,window.width,19);
Titlebar.Caption := 'GUIMain';
TJUIWidget(StartServerButton) := Window.CreateWidget(TJUIButton);
StartServerButton.LocalRect := J2DRect(5,25,80,45);
StartServerButton.Caption := 'Start Server';
StartServerButton.OnMouseClick := @StartServerClick;
TJUIWidget(StartClientButton) := Window.CreateWidget(TJUIButton);
StartClientButton.LocalRect := J2DRect(95,25,170,45);
StartClientButton.Caption := 'Start Client';
StartClientButton.OnMouseClick := @StartClientClick;
TJUIWidget(EditBox) := Window.CreateWidget(TJUIEditBox);
EditBox.LocalRect := J2DRect(180,25,290,41);
TJUIWidget(ListView) := Window.CreateWidget(TJUIListView);
ListView.LocalRect := J2DRect(5,55,290,305);
ListView.Anchor.Right := true;
listview.anchor.bottom := true;
listview.Columns[0].Caption := 'I love';
listview.AddColumn('Fish');
listview.AddColumn('Fingers');
listview.AddItem('It''s all good');
listview.Items[ListView.NumItems-1].SubItems[0].caption := 'This Is A SubItem';
end;
destructor TCCGUIMain.destroy;
begin
inherited;
end;
procedure TCCGUIMain.StartServerClick(ButtonMessage : TMsgMouseButton);
begin
if assigned(CCGlobal.PINServer) then
begin
CCGlobal.PINServer.OutBoundRelay := nil;
freeandnil(CCGlobal.ServerState);
freeandnil(CCGlobal.PINServer);
end else
begin
CCGlobal.PINServer := TPINServer.Create('0.0.0.0',6969);
CCGlobal.ServerState := TCCServerState.create;
CCGlobal.ServerState.OutBoundRelay := CCGlobal.PINServer;
CCGlobal.PINServer.OutBoundRelay := CCGlobal.ServerState;
CCGlobal.PINServer.Listen;
end;
end;
procedure TCCGUIMain.StartClientClick(ButtonMessage : TMsgMouseButton);
begin
if assigned(CCGlobal.PINClient) then
begin
CCGlobal.PINClient.OutBoundRelay := nil;
freeandnil(CCGlobal.ClientState);
freeandnil(CCGlobal.PINClient);
end else
begin
CCGlobal.PINClient := TPINClient.Create('192.168.0.1',6969);
CCGlobal.ClientState := TCCClientState.create;
CCGlobal.ClientState.OutBoundRelay := CCGlobal.PINClient;
CCGlobal.PINClient.OutBoundRelay := CCGlobal.ClientState;
CCGlobal.PINClient.Connect;
end;
end;
end.
So yes, I shall be releasing this at some point but I'm looking for another developer to help me with the workload. There's still a number of widgets I need to re-code and I may need help on moving to a faster VBO rendering method (need new font units, is GLViewPort depreciated? EDIT : GLViewPort is *not* depreciated
Bookmarks