⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gui.cpp

📁 泡泡堂单机版(含ASL游戏引擎源码 泡泡堂单机版(含ASL游戏引擎源码
💻 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 + -