?? gui.cpp
字號:
//-----------------------------------------------------------------------------
//
// ____ Azure Star Game Engine 藍星游戲引擎 ____
//
// Copyright (c) 2006, 藍星工作室
// All rights reserved.
//
// 文件名稱: gui.cpp
// 摘 要: GUI演示、壓縮包讀取演示
//
// 當前版本: 1.0
// 作 者: 湯 祺
// 創建日期: 2006-8-12
//
//-----------------------------------------------------------------------------
#include "asl_winapp.h"
#include "asl_ini.h"
using namespace ASL;
#define SCREEN_WIDTH 800
#define SCREEN_HEIGHT 600
class MyForm : public ASLForm
{
private:
ASLBitmap pan1bg;
ASLBitmap pan2bg;
ASLBitmap pan3bg;
ASLBitmap btn;
ASLBitmap btnbig;
ASLBitmap check;
ASLBitmap slot;
ASLBitmap slider;
ASLBitmap edit;
ASLFont font;
bool doing;
ASLSound *psndClick;
public:
// Panel1 elements
ASLPanel Panel1;
ASLLabel Label1;
ASLLabel Label2;
ASLLabel Label3;
ASLLabel Label4;
ASLLabel Label5;
ASLLabel Label6;
ASLLabel Label7;
ASLLabel Label8;
ASLLabel Label9;
ASLCheckBox CheckBox1;
ASLCheckBox CheckBox2;
ASLCheckBox CheckBox3;
ASLCheckBox CheckBox4;
ASLCheckBox CheckBox5;
ASLImage Image1;
ASLImage Image2;
ASLImage Image3;
ASLScrollBar ScrollBar1;
ASLScrollBar ScrollBar2;
ASLButton Button1;
ASLEdit Edit1;
// Panel2 elements
ASLPanel Panel2;
ASLButton ButtonGame;
ASLButton ButtonVideo;
ASLButton ButtonSound;
// Panel3 elements
ASLPanel Panel3;
ASLButton ButtonOK;
ASLButton ButtonCancel;
public:
void Init()
{
// Prepare
doing = false;
HFONT f = CreateFontFast("黑體", 14);
font.Create(f, true, 128);
ASLFileLoader Loader;
Loader.SetZipApp("Pic.zip");
// Load bitmaps
pan1bg.LoadBMP(Loader.Load("panel1.bmp"));
pan2bg.LoadBMP(Loader.Load("panel2.bmp"));
pan3bg.LoadBMP(Loader.Load("panel3.bmp"));
btn.LoadBMP(Loader.Load("btn.bmp"));
btn.SetColorKey();
btnbig.LoadBMP(Loader.Load("btnbig.bmp"));
btnbig.SetColorKey();
check.LoadBMP(Loader.Load("checkbox.bmp"));
slot.LoadBMP(Loader.Load("slot.bmp"));
slider.LoadBMP(Loader.Load("slider.bmp"));
slider.SetColorKey();
edit.LoadBMP(Loader.Load("edit.bmp"));
// Load sound
AUDIO.SetDirApp("Snd");
psndClick = AUDIO.LoadEffect("click.wav");
// MyForm setup
Create(NULL, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, font, RGB16(200, 200, 0));
// Panel1 setup
Panel1.Create(this, 10, -pan1bg.GetHeight(), pan1bg);
Label1.Create(&Panel1, 20, 90, "游戲性設置");
Label1.SetFontColor(clWhite);
Label2.Create(&Panel1, 20, 110, "鼠標滾動:");
Label3.Create(&Panel1, 30, 130, "慢");
Label3.SetFontColor(clWhite);
Label4.Create(&Panel1, 350, 130, "快");
Label4.SetFontColor(clWhite);
Label5.Create(&Panel1, 20, 185, "鍵盤滾動:");
Label6.Create(&Panel1, 30, 205, "慢");
Label6.SetFontColor(clWhite);
Label7.Create(&Panel1, 350, 205, "快");
Label7.SetFontColor(clWhite);
Label8.Create(&Panel1, 20, 380, "游戲端口");
Label9.Create(&Panel1, 20, 425, "聊天支持");
CheckBox1.Create(&Panel1, 20, 152, check, "取消鼠標滾動");
CheckBox2.Create(&Panel1, 20, 227, check, "高級工具提示");
CheckBox2.Check();
CheckBox3.Create(&Panel1, 20, 257, check, "子組順序修改鍵");
CheckBox4.Create(&Panel1, 20, 287, check, "啟動隊形移動開關");
CheckBox4.Check();
CheckBox4.Disable();
CheckBox5.Create(&Panel1, 20, 317, check, "自定義快捷鍵");
Image1.Create(&Panel1, 53, 130, slot);
Image2.Create(&Panel1, 53, 205, slot);
Image3.Create(&Panel1, 110, 370, edit);
ScrollBar1.Create(&Panel1, 53, 130, sbHorizontal, slider, Image1.GetWidth());
ScrollBar1.SetPosition(40);
ScrollBar2.Create(&Panel1, 53, 205, sbHorizontal, slider, Image2.GetWidth());
ScrollBar2.SetPosition(60);
Button1.Create(&Panel1, 100, 420, btnbig, "簡體中文(預設)");
Edit1.Create(&Panel1, 120, 380, 60);
Edit1.SetText("6112");
Edit1.SetFontColor(clWhite);
Edit1.SetCaretColor(clWhite);
Edit1.SetFocus();
// Panel2 setup
Panel2.Create(this, 545, 0, pan2bg);
ButtonGame.Create(&Panel2, 49, 128, btnbig, "游戲性(G)");
ButtonGame.SetDownOffset(-1, 3);
ON_CLICK(&ButtonGame, ButtonCtrlClick);
ButtonVideo.Create(&Panel2, 49, 187, btnbig, "圖像(V)");
ButtonVideo.SetDownOffset(-1, 3);
ON_CLICK(&ButtonVideo, ButtonCtrlClick);
ButtonSound.Create(&Panel2, 49, 246, btnbig, "聲音(S)");
ButtonSound.SetDownOffset(-1, 3);
ON_CLICK(&ButtonSound, ButtonCtrlClick);
// Panel3 setup
Panel3.Create(this, 560, 452, pan3bg);
ButtonOK.Create(&Panel3, 46, 28, btn, "確定(O)");
ButtonOK.SetDownOffset(-1, 3);
ButtonOK.Disable();
ButtonCancel.Create(&Panel3, 46, 80, btn, "取消(A)");
ButtonCancel.SetDownOffset(-1, 3);
ON_CLICK(&ButtonCancel, ButtonCancelClick);
}
void Update(float fDelta)
{
// Handle panel moving
static bool up = true;
if (doing)
{
int y = Panel1.GetTop();
if (up)
{
y -= 20;
}
else
{
y += 20;
}
if (y <= -pan1bg.GetHeight())
{
up = false;
}
else if (y >= 0)
{
y = 0;
doing = false;
up = true;
ButtonGame.Enable();
ButtonVideo.Enable();
ButtonSound.Enable();
ButtonCancel.Enable();
}
Panel1.SetTop(y);
}
}
void ButtonCtrlClick()
{
psndClick->Play();
doing = true;
ButtonGame.Disable();
ButtonVideo.Disable();
ButtonSound.Disable();
ButtonCancel.Disable();
Edit1.SetFocus();
}
void ButtonCancelClick()
{
Application->Quit();
}
};
//-----------------------------------------------------------------------------
class MyApp : public ASLWinApp
{
private:
ASLBitmap bg;
ASLBitmap cursor;
MyForm form;
public:
void Init()
{
Create(SCREEN_WIDTH, SCREEN_HEIGHT, "GAME", false, false, true);
LockFPS(60);
// Load background and cursor
ASLFileLoader Loader;
Loader.SetZipApp("Pic.zip");
bg.LoadBMP(Loader.Load("bg.bmp"));
cursor.LoadBMP(Loader.Load("cursor.bmp"));
POINT pt = { 4, 2 };
cursor.SetHotspot(pt);
form.Init();
}
void OnIdle()
{
// Update
if (INPUT.IsKeyJustDown(VK_ESCAPE))
{
Quit();
}
if (INPUT.IsKeyJustDown(VK_F4))
{
SCREEN.SwitchScreen();
}
// Draw
bg.Draw(SCREEN, 0, 0);
GUI.Draw();
SCREEN.TextOut(clWhite, 10, 10, "FPS: %.3d 冰峰王座界面模擬", GetFPS());
cursor.DrawAlphaChannel(SCREEN, INPUT.GetMousePosX(), INPUT.GetMousePosY());
}
};
int APIENTRY WinMain(HINSTANCE, HINSTANCE, LPTSTR, int)
{
MyApp theApp;
try
{
Application->Init();
Application->Run();
}
catch (ASLException &exception)
{
Application->ShowException(exception);
}
catch (...)
{
ASLSimpleException exception("出現嚴重錯誤, 程序即將關閉");
Application->ShowException(exception);
}
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -