mirror of
https://github.com/beefytech/Beef.git
synced 2025-07-04 23:36:00 +02:00
Working on installer, fixing more Win32 issues
Throwing error on member references with ".." cascade token outside invocations (ie: "ts..mA = 123") Fixed 'Thread.ModuleTLSIndex' error - which caused us TLS lookup failures in Beef DLLs Fixed some hotswap errors Made BeefPerf shut down properly Fixed an 'int literal' FixIntUnknown issue where rhs was System.Object which caused an illegal boxing Fixed COFF::LocateSymbol issues with Win32 and also with linking to static libraries - showed up with hot-linking in fmod when hot-adding a floating point mod Fixed a couple memory leaks Fixed alignment issue in COFF::ParseCompileUnit
This commit is contained in:
parent
aad0a640c5
commit
b63a243fd7
73 changed files with 2474 additions and 293 deletions
|
@ -2,6 +2,7 @@ FileVersion = 1
|
|||
|
||||
[Project]
|
||||
Name = "Stub"
|
||||
TargetType = "BeefWindowsApplication"
|
||||
StartupObject = "BIStub.Program"
|
||||
|
||||
[Configs.Debug.Win64]
|
||||
|
|
|
@ -147,6 +147,8 @@ namespace BIStub
|
|||
}
|
||||
|
||||
startFunc(=> UI_Install, => UI_GetProgress, => UI_Cancel);
|
||||
|
||||
Windows.FreeLibrary(lib);
|
||||
}
|
||||
|
||||
void Run()
|
||||
|
@ -155,7 +157,7 @@ namespace BIStub
|
|||
Directory.GetCurrentDirectory(cwd);
|
||||
StartUI(cwd);
|
||||
|
||||
CheckPE();
|
||||
/*CheckPE();
|
||||
|
||||
ZipFile zipFile = scope .();
|
||||
zipFile.Open(@"c:\\temp\\build_1827.zip");
|
||||
|
@ -163,7 +165,7 @@ namespace BIStub
|
|||
|
||||
CabFile cabFile = scope .();
|
||||
cabFile.Init();
|
||||
cabFile.Copy();
|
||||
cabFile.Copy();*/
|
||||
}
|
||||
|
||||
static int Main(String[] args)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
FileVersion = 1
|
||||
Dependencies = {corlib = "*", Beefy2D = "*"}
|
||||
Dependencies = {corlib = "*", Beefy2D = "*", SDL2 = "*"}
|
||||
|
||||
[Project]
|
||||
Name = "StubUI"
|
||||
|
@ -11,7 +11,7 @@ DefaultNamespace = "BIStubUI"
|
|||
TargetDirectory = "$(WorkspaceDir)/../dist"
|
||||
TargetName = "$(ProjectName)_d"
|
||||
OtherLinkFlags = "$(LinkFlags) BeefySysLib64_d.lib"
|
||||
PostBuildCmds = ["Sleep(1000)", "cmd.exe /c echo Hey!", "CopyFilesIfNewer(\"$(WorkspaceDir)/../../../IDE/dist/BeefySysLib*.*\", \"$(WorkspaceDir)/../dist\")"]
|
||||
BeefLibType = "DynamicDebug"
|
||||
DebugCommand = "$(WorkspaceDir)\\..\\dist\\Stub_d.exe"
|
||||
|
||||
[Configs.Release.Win64]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
FileVersion = 1
|
||||
Projects = {StubUI = {Path = "."}, Beefy2D = "*"}
|
||||
Unlocked = ["corlib"]
|
||||
Projects = {StubUI = {Path = "."}, Beefy2D = "*", SDL2 = "*"}
|
||||
Unlocked = ["Beefy2D", "corlib", "SDL2"]
|
||||
|
||||
[Workspace]
|
||||
StartupProject = "StubUI"
|
||||
|
|
|
@ -1,36 +1,124 @@
|
|||
using System;
|
||||
using Beefy;
|
||||
using Beefy.widgets;
|
||||
using Beefy.geom;
|
||||
using Beefy.gfx;
|
||||
|
||||
namespace BIStubUI
|
||||
{
|
||||
class BIApp : BFApp
|
||||
{
|
||||
static int a = 123;
|
||||
|
||||
public function void InstallFunc(StringView dest, StringView filter);
|
||||
public function int ProgressFunc();
|
||||
public function void CancelFunc();
|
||||
|
||||
const int cWidth = 900;
|
||||
const int cHeight = 620;
|
||||
|
||||
public Font mHeaderFont ~ delete _;
|
||||
public Font mBodyFont ~ delete _;
|
||||
public Font mBtnFont ~ delete _;
|
||||
public Font mBoxFont ~ delete _;
|
||||
|
||||
public InstallFunc mInstallFunc;
|
||||
public ProgressFunc mProgressFunc;
|
||||
public CancelFunc mCancelFunc;
|
||||
|
||||
Widget mRootWidget;
|
||||
WidgetWindow mMainWindow;
|
||||
public Board mBoard;
|
||||
public Widget mRootWidget;
|
||||
public WidgetWindow mMainWindow;
|
||||
|
||||
const int cWidth = 700;
|
||||
const int cHeight = 700;
|
||||
public bool mCancelling;
|
||||
public bool mWantRehup;
|
||||
public int32 mBoardDelay;
|
||||
public bool mClosing;
|
||||
|
||||
public ~this()
|
||||
{
|
||||
Images.Dispose();
|
||||
}
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
|
||||
BFWindow.Flags windowFlags = BFWindow.Flags.Border | BFWindow.Flags.SysMenu | //| BFWindow.Flags.CaptureMediaKeys |
|
||||
BFWindow.Flags.Caption | BFWindow.Flags.Minimize | BFWindow.Flags.QuitOnClose;
|
||||
|
||||
BFWindow.Flags windowFlags = .QuitOnClose
|
||||
| .DestAlpha
|
||||
;
|
||||
|
||||
GetWorkspaceRect(var workX, var workY, var workWidth, var workHeight);
|
||||
|
||||
mRootWidget = new Widget();
|
||||
mMainWindow = new WidgetWindow(null, "Beef Installer", 0, 0, cWidth, cHeight, windowFlags, mRootWidget);
|
||||
mMainWindow.SetMinimumSize(480, 360);
|
||||
mMainWindow = new WidgetWindow(null, "Beef Installer",
|
||||
workX + (workWidth - cWidth)/2, workY + (workHeight - cHeight) / 2, cWidth, cHeight, windowFlags, mRootWidget);
|
||||
mMainWindow.mIsMainWindow = true;
|
||||
mMainWindow.mOnHitTest.Add(new (absX, absY) =>
|
||||
{
|
||||
float x = absX - mMainWindow.mX;
|
||||
float y = absY - mMainWindow.mY;
|
||||
|
||||
Widget aWidget = mRootWidget.FindWidgetByCoords(x, y);
|
||||
if ((aWidget != null) && (aWidget != mBoard))
|
||||
return .NotHandled;
|
||||
|
||||
if (Rect(60, 24, 700, 420).Contains(x, y))
|
||||
return .Caption;
|
||||
|
||||
return .NotHandled;
|
||||
});
|
||||
|
||||
Font CreateFont(StringView srcName, float fontSize)
|
||||
{
|
||||
Font font = new Font();
|
||||
font.Load(srcName, fontSize);
|
||||
font.AddAlternate("Segoe UI Symbol", fontSize);
|
||||
font.AddAlternate("Segoe UI Historic", fontSize);
|
||||
font.AddAlternate("Segoe UI Emoji", fontSize);
|
||||
return font;
|
||||
}
|
||||
|
||||
mHeaderFont = CreateFont("Segoe UI Bold", 42);
|
||||
mBodyFont = CreateFont("Segoe UI", 22);
|
||||
mBoxFont = CreateFont("Segoe UI", 18);
|
||||
mBtnFont = CreateFont("Segoe UI", 32);
|
||||
|
||||
Images.Init();
|
||||
Sounds.Init();
|
||||
|
||||
SetupBoard();
|
||||
}
|
||||
|
||||
void SetupBoard()
|
||||
{
|
||||
mBoard = new .();
|
||||
mRootWidget.AddWidget(mBoard);
|
||||
mBoard.Resize(0, 0, cWidth, cHeight);
|
||||
mBoard.SetFocus();
|
||||
}
|
||||
|
||||
public override void Update(bool batchStart)
|
||||
{
|
||||
base.Update(batchStart);
|
||||
|
||||
if (mCancelling)
|
||||
{
|
||||
mClosing = true;
|
||||
if ((mBoard != null) && (mBoard.mIsClosed))
|
||||
Stop();
|
||||
}
|
||||
|
||||
if (mWantRehup)
|
||||
{
|
||||
mBoard.RemoveSelf();
|
||||
DeleteAndNullify!(mBoard);
|
||||
mBoardDelay = 30;
|
||||
mWantRehup = false;
|
||||
}
|
||||
|
||||
if ((mBoardDelay > 0) && (--mBoardDelay == 0))
|
||||
SetupBoard();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
563
BeefTools/BeefInstall/StubUI/src/Board.bf
Normal file
563
BeefTools/BeefInstall/StubUI/src/Board.bf
Normal file
|
@ -0,0 +1,563 @@
|
|||
using Beefy.widgets;
|
||||
using Beefy.geom;
|
||||
using Beefy.gfx;
|
||||
using System.Diagnostics;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace BIStubUI
|
||||
{
|
||||
class BiButtonWidget : ButtonWidget
|
||||
{
|
||||
public Image mImage;
|
||||
public Image mImageHi;
|
||||
|
||||
public override void Draw(Graphics g)
|
||||
{
|
||||
if (mMouseOver && mMouseDown)
|
||||
g.Draw(mImageHi);
|
||||
if (mMouseOver)
|
||||
g.Draw(mImageHi);
|
||||
else
|
||||
g.Draw(mImage);
|
||||
|
||||
/*using (g.PushColor(0x8000FF00))
|
||||
g.FillRect(0, 0, mWidth, mHeight);*/
|
||||
}
|
||||
|
||||
public override void DrawAll(Graphics g)
|
||||
{
|
||||
using (g.PushColor(mDisabled ? 0xD0A0A0A0 : 0xFFFFFFFF))
|
||||
base.DrawAll(g);
|
||||
}
|
||||
|
||||
public override void MouseEnter()
|
||||
{
|
||||
base.MouseEnter();
|
||||
if (!mDisabled)
|
||||
{
|
||||
gApp.SetCursor(.Hand);
|
||||
gApp.mSoundManager.PlaySound(Sounds.sMouseOver);
|
||||
}
|
||||
}
|
||||
|
||||
public override void MouseDown(float x, float y, int32 btn, int32 btnCount)
|
||||
{
|
||||
base.MouseDown(x, y, btn, btnCount);
|
||||
if (!mDisabled)
|
||||
gApp.mSoundManager.PlaySound(Sounds.sButtonPress);
|
||||
}
|
||||
|
||||
public override void MouseLeave()
|
||||
{
|
||||
base.MouseLeave();
|
||||
gApp.SetCursor(.Pointer);
|
||||
}
|
||||
}
|
||||
|
||||
class BiDialogButton : BiButtonWidget
|
||||
{
|
||||
public String mLabel ~ delete _;
|
||||
|
||||
public override void Draw(Graphics g)
|
||||
{
|
||||
base.Draw(g);
|
||||
|
||||
g.SetFont(gApp.mBtnFont);
|
||||
g.DrawString(mLabel, 0, 14, .Centered, mWidth);
|
||||
}
|
||||
}
|
||||
|
||||
class BiCheckbox : CheckBox
|
||||
{
|
||||
public State mState;
|
||||
public String mLabel ~ delete _;
|
||||
|
||||
public override bool Checked
|
||||
{
|
||||
get
|
||||
{
|
||||
return mState != .Unchecked;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
gApp.mSoundManager.PlaySound(Sounds.sChecked);
|
||||
mState = value ? .Checked : .Unchecked;
|
||||
}
|
||||
}
|
||||
|
||||
public override State State
|
||||
{
|
||||
get
|
||||
{
|
||||
return mState;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
mState = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Draw(Graphics g)
|
||||
{
|
||||
if (mState == .Checked)
|
||||
g.Draw(Images.sChecked);
|
||||
else
|
||||
g.Draw(Images.sUnchecked);
|
||||
|
||||
g.SetFont(gApp.mBodyFont);
|
||||
using (g.PushColor(0xFF000000))
|
||||
g.DrawString(mLabel, 40, 2);
|
||||
}
|
||||
|
||||
public override void MouseEnter()
|
||||
{
|
||||
base.MouseEnter();
|
||||
gApp.SetCursor(.Hand);
|
||||
}
|
||||
|
||||
public override void MouseLeave()
|
||||
{
|
||||
base.MouseLeave();
|
||||
gApp.SetCursor(.Pointer);
|
||||
}
|
||||
}
|
||||
|
||||
class BiInstallPathBox : Widget
|
||||
{
|
||||
public String mInstallPath = new .() ~ delete _;
|
||||
ImageWidget mBrowseButton;
|
||||
|
||||
public this()
|
||||
{
|
||||
mBrowseButton = new ImageWidget();
|
||||
mBrowseButton.mImage = Images.sBrowse;
|
||||
mBrowseButton.mDownImage = Images.sBrowseDown;
|
||||
mBrowseButton.mOnMouseClick.Add(new (mouseArgs) =>
|
||||
{
|
||||
var folderDialog = scope FolderBrowserDialog();
|
||||
if (folderDialog.ShowDialog(mWidgetWindow).GetValueOrDefault() == .OK)
|
||||
{
|
||||
var selectedPath = scope String..AppendF(folderDialog.SelectedPath);
|
||||
mInstallPath.Set(selectedPath);
|
||||
}
|
||||
});
|
||||
AddWidget(mBrowseButton);
|
||||
}
|
||||
|
||||
public void ResizeComponenets()
|
||||
{
|
||||
mBrowseButton.Resize(mWidth - 30, 2, Images.sBrowse.mWidth, Images.sBrowse.mHeight);
|
||||
}
|
||||
|
||||
public override void Resize(float x, float y, float width, float height)
|
||||
{
|
||||
base.Resize(x, y, width, height);
|
||||
ResizeComponenets();
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
base.Update();
|
||||
ResizeComponenets();
|
||||
}
|
||||
|
||||
public override void Draw(Graphics g)
|
||||
{
|
||||
base.Draw(g);
|
||||
|
||||
g.DrawButton(Images.sTextBox, 0, 0, mWidth);
|
||||
using (g.PushColor(0xFF000000))
|
||||
{
|
||||
g.SetFont(gApp.mBodyFont);
|
||||
g.DrawString("Installation path", 0, -32);
|
||||
g.SetFont(gApp.mBoxFont);
|
||||
g.DrawString(mInstallPath, 4, 0, .Left, mWidth - 36, .Ellipsis);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Board : Widget
|
||||
{
|
||||
const float cBodyX = 0;
|
||||
const float cBodyY = 20;
|
||||
|
||||
LabelWidget mHeaderLabel;
|
||||
BiButtonWidget mCloseButton;
|
||||
BiDialogButton mCancelButton;
|
||||
BiDialogButton mInstallButton;
|
||||
BiCheckbox mInstallForAllCheckbox;
|
||||
BiCheckbox mAddToStartCheckbox;
|
||||
BiCheckbox mAddToDesktopCheckbox;
|
||||
BiCheckbox mStartAfterCheckbox;
|
||||
BiInstallPathBox mInstallPathBox;
|
||||
|
||||
float mScale = 0.35f;
|
||||
float mScaleVel = 0.2f;
|
||||
|
||||
float mSurprisePct = 1.0f;
|
||||
float mHeadRaise = 1.0f;
|
||||
float mEatPct;
|
||||
|
||||
int mCloseTicks;
|
||||
public bool mIsClosed;
|
||||
|
||||
public bool mInstalling;
|
||||
public float mInstallPct = 0.5f;
|
||||
|
||||
public this()
|
||||
{
|
||||
mHeaderLabel = new LabelWidget();
|
||||
mHeaderLabel.mLabel = new String("Beef Development Tools");
|
||||
mHeaderLabel.mAlign = .Centered;
|
||||
mHeaderLabel.mColor = 0xFF000000;
|
||||
mHeaderLabel.mFont = gApp.mHeaderFont;
|
||||
mHeaderLabel.mMouseVisible = false;
|
||||
AddWidget(mHeaderLabel);
|
||||
|
||||
mCloseButton = new BiButtonWidget();
|
||||
mCloseButton.mImage = Images.sClose;
|
||||
mCloseButton.mImageHi = Images.sCloseHi;
|
||||
mCloseButton.mOnMouseClick.Add(new (mouseArgs) =>
|
||||
{
|
||||
gApp.mCancelling = true;
|
||||
});
|
||||
mCloseButton.mMouseInsets = new Insets(4, 4, 4, 4);
|
||||
AddWidget(mCloseButton);
|
||||
|
||||
mInstallForAllCheckbox = new BiCheckbox();
|
||||
mInstallForAllCheckbox.mState = .Checked;
|
||||
mInstallForAllCheckbox.mLabel = new String("Install for all users");
|
||||
AddWidget(mInstallForAllCheckbox);
|
||||
|
||||
mAddToStartCheckbox = new BiCheckbox();
|
||||
mAddToStartCheckbox.mState = .Checked;
|
||||
mAddToStartCheckbox.mLabel = new String("Add to Start menu");
|
||||
AddWidget(mAddToStartCheckbox);
|
||||
|
||||
mAddToDesktopCheckbox = new BiCheckbox();
|
||||
mAddToDesktopCheckbox.mState = .Checked;
|
||||
mAddToDesktopCheckbox.mLabel = new String("Add to desktop");
|
||||
AddWidget(mAddToDesktopCheckbox);
|
||||
|
||||
mStartAfterCheckbox = new BiCheckbox();
|
||||
mStartAfterCheckbox.mState = .Checked;
|
||||
mStartAfterCheckbox.mLabel = new String("Run after install");
|
||||
AddWidget(mStartAfterCheckbox);
|
||||
|
||||
mInstallPathBox = new BiInstallPathBox();
|
||||
AddWidget(mInstallPathBox);
|
||||
|
||||
mCancelButton = new BiDialogButton();
|
||||
mCancelButton.mLabel = new .("Cancel");
|
||||
mCancelButton.mImage = Images.sButton;
|
||||
mCancelButton.mImageHi = Images.sButtonHi;
|
||||
mCancelButton.mOnMouseClick.Add(new (mouseArgs) =>
|
||||
{
|
||||
gApp.mCancelling = true;
|
||||
});
|
||||
mCancelButton.mMouseInsets = new Insets(4, 4, 4, 4);
|
||||
AddWidget(mCancelButton);
|
||||
|
||||
mInstallButton = new BiDialogButton();
|
||||
mInstallButton.mLabel = new .("Install");
|
||||
mInstallButton.mImage = Images.sButton;
|
||||
mInstallButton.mImageHi = Images.sButtonHi;
|
||||
mInstallButton.mOnMouseClick.Add(new (mouseArgs) =>
|
||||
{
|
||||
StartInstall();
|
||||
});
|
||||
mInstallButton.mMouseInsets = new Insets(4, 4, 4, 4);
|
||||
AddWidget(mInstallButton);
|
||||
|
||||
////
|
||||
|
||||
int pidl = 0;
|
||||
Windows.SHGetSpecialFolderLocation(gApp.mMainWindow.HWND, Windows.CSIDL_PROGRAM_FILES, ref pidl);
|
||||
if (pidl != 0)
|
||||
{
|
||||
char8* selectedPathCStr = scope char8[Windows.MAX_PATH]*;
|
||||
Windows.SHGetPathFromIDList(pidl, selectedPathCStr);
|
||||
mInstallPathBox.mInstallPath.Set(StringView(selectedPathCStr));
|
||||
}
|
||||
else
|
||||
{
|
||||
mInstallPathBox.mInstallPath.Set(@"C:\Program Files");
|
||||
}
|
||||
mInstallPathBox.mInstallPath.Append(@"\BeefLang");
|
||||
}
|
||||
|
||||
void StartInstall()
|
||||
{
|
||||
mInstalling = true;
|
||||
mInstallButton.mDisabled = true;
|
||||
mInstallButton.mMouseVisible = false;
|
||||
mInstallPathBox.mVisible = false;
|
||||
}
|
||||
|
||||
public override void Draw(Graphics g)
|
||||
{
|
||||
float bodyX = cBodyX;
|
||||
float bodyY = cBodyY;
|
||||
|
||||
g.Draw(Images.sBody, bodyX, bodyY);
|
||||
|
||||
float headRaise = mHeadRaise;
|
||||
headRaise += Math.Sin(Math.Clamp((mEatPct - 0.2f) * 1.4f, 0, 1.0f) * Math.PI_f*6) * 0.02f;
|
||||
|
||||
float headX = bodyX + 664 - headRaise * 6;
|
||||
float headY = bodyY + 192 - headRaise * 30;
|
||||
|
||||
headY += Math.Clamp(Math.Sin(Math.PI_f * mEatPct) * 3.0f, 0, 1) * 8.0f;
|
||||
|
||||
Images.sHead.mPixelSnapping = .Never;
|
||||
Images.sEyesOpen.mPixelSnapping = .Never;
|
||||
Images.sEyesClosed.mPixelSnapping = .Never;
|
||||
g.Draw(Images.sHead, headX, headY);
|
||||
g.Draw((mSurprisePct > 0) ? Images.sEyesOpen : Images.sEyesClosed, headX + 70, headY + 190);
|
||||
|
||||
if (mInstalling)
|
||||
{
|
||||
float installDiv = 1000.0f;
|
||||
//mInstallPct = (mUpdateCnt % installDiv) / installDiv;
|
||||
|
||||
//mInstallPct = 1.0f;
|
||||
|
||||
float totalWidth = 410;
|
||||
float fillWidth = totalWidth * (mInstallPct*0.9f + 0.1f);
|
||||
|
||||
float barX = 200;
|
||||
float barY = 280;
|
||||
|
||||
float barHeight = Images.sPBBarBottom.mHeight;
|
||||
using (g.PushClip(barX, barY, totalWidth, barHeight))
|
||||
{
|
||||
g.DrawButton(Images.sPBBarBottom, barX, barY, totalWidth);
|
||||
|
||||
Color colorLeft = 0x800288E9;
|
||||
Color colorRight = 0x80FFFFFF;
|
||||
g.FillRectGradient(barX, barY, fillWidth, barHeight, colorLeft, colorRight, colorLeft, colorRight);
|
||||
|
||||
float pct = (mUpdateCnt % 60) / 60.0f;
|
||||
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
Images.sPBBarHilite.mPixelSnapping = .Never;
|
||||
using (g.PushColor(0x22FFFFFF))
|
||||
g.Draw(Images.sPBBarHilite, barX - 16 - totalWidth + fillWidth + (i + pct) * 26, barY + 6);
|
||||
}
|
||||
|
||||
g.DrawButton(Images.sPBBarEmpty, barX + fillWidth - 30, barY + 5, totalWidth - fillWidth + 40);
|
||||
|
||||
g.DrawButton(Images.sPBFrameTop, barX, barY, totalWidth);
|
||||
|
||||
g.DrawButton(Images.sPBFrameGlow, barX, barY, fillWidth);
|
||||
}
|
||||
}
|
||||
|
||||
/*g.SetFont(gApp.mHdrFont);
|
||||
using (g.PushColor(0xFF000000))
|
||||
g.DrawString("Beef Development Tools", 400, 20, .Centered);*/
|
||||
}
|
||||
|
||||
public override void MouseMove(float x, float y)
|
||||
{
|
||||
if (Rect(60, 24, 700, 420).Contains(x, y))
|
||||
{
|
||||
gApp.SetCursor(.SizeNESW);
|
||||
}
|
||||
else
|
||||
{
|
||||
gApp.SetCursor(.Pointer);
|
||||
}
|
||||
|
||||
base.MouseMove(x, y);
|
||||
}
|
||||
|
||||
public override void DrawAll(Graphics g)
|
||||
{
|
||||
int cBodyX = 0;
|
||||
int cBodyY = 0;
|
||||
|
||||
/*using (g.PushColor(0x80FF0000))
|
||||
g.FillRect(0, 0, mWidth, mHeight);*/
|
||||
|
||||
//float scaleX = (Math.Cos(mUpdateCnt * 0.1f) + 1.0f) * 0.5f;
|
||||
//float scaleY = scaleX;
|
||||
float scaleX = mScale;
|
||||
float scaleY = mScale;
|
||||
|
||||
if ((Math.Abs(scaleX - 1.0f) < 0.001) && (Math.Abs(scaleY - 1.0f) < 0.001))
|
||||
base.DrawAll(g);
|
||||
else using (g.PushScale(scaleX, scaleY, cBodyX + 400, cBodyY + 560))
|
||||
base.DrawAll(g);
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
ResizeComponents();
|
||||
|
||||
if (gApp.mClosing)
|
||||
{
|
||||
if (mCloseTicks == 0)
|
||||
{
|
||||
gApp.mSoundManager.PlaySound(Sounds.sAbort);
|
||||
mScaleVel = 0.055f;
|
||||
}
|
||||
mCloseTicks++;
|
||||
|
||||
mScaleVel *= 0.90f;
|
||||
mScaleVel -= 0.01f;
|
||||
mScale += mScaleVel;
|
||||
mSurprisePct = 1.0f;
|
||||
mHeadRaise = Math.Clamp(mHeadRaise + 0.2f, 0, 1.0f);
|
||||
|
||||
if (mScale <= 0)
|
||||
{
|
||||
mScale = 0.0f;
|
||||
}
|
||||
|
||||
if (mCloseTicks == 60)
|
||||
mIsClosed = true;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (mUpdateCnt == 1)
|
||||
gApp.mSoundManager.PlaySound(Sounds.sBoing);
|
||||
|
||||
float sizeTarget = Math.Min(0.5f + mUpdateCnt * 0.05f, 1.0f);
|
||||
|
||||
float scaleDiff = sizeTarget - mScale;
|
||||
mScaleVel += scaleDiff * 0.05f;
|
||||
mScaleVel *= 0.80f;
|
||||
mScale += mScaleVel;
|
||||
|
||||
mSurprisePct = Math.Max(mSurprisePct - 0.005f, 0);
|
||||
if (mUpdateCnt > 240)
|
||||
{
|
||||
mHeadRaise = Math.Max(mHeadRaise * 0.95f - 0.01f, 0);
|
||||
}
|
||||
|
||||
if (mEatPct == 0.0f)
|
||||
{
|
||||
if ((mUpdateCnt == 600) || (mUpdateCnt % 2400 == 0))
|
||||
{
|
||||
mEatPct = 0.0001f;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
let prev = mEatPct;
|
||||
mEatPct += 0.004f;
|
||||
if ((prev < 0.2f) && (mEatPct >= 0.2f))
|
||||
gApp.mSoundManager.PlaySound(Sounds.sEating);
|
||||
|
||||
if (mEatPct >= 1.0f)
|
||||
{
|
||||
//Debug.WriteLine("Eat done");
|
||||
mEatPct = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (mUpdateCnt % 2200 == 0)
|
||||
{
|
||||
mSurprisePct = 0.5f;
|
||||
}
|
||||
}
|
||||
|
||||
public override void UpdateAll()
|
||||
{
|
||||
base.UpdateAll();
|
||||
|
||||
if (mWidgetWindow.IsKeyDown(.Control))
|
||||
{
|
||||
for (int i < 2)
|
||||
base.UpdateAll();
|
||||
}
|
||||
}
|
||||
|
||||
public override void MouseDown(float x, float y, int32 btn, int32 btnCount)
|
||||
{
|
||||
base.MouseDown(x, y, btn, btnCount);
|
||||
}
|
||||
|
||||
public override void KeyDown(KeyCode keyCode, bool isRepeat)
|
||||
{
|
||||
base.KeyDown(keyCode, isRepeat);
|
||||
|
||||
if (keyCode == .Space)
|
||||
{
|
||||
gApp.mWantRehup = true;
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateComponent(Widget widget, int updateOffset, float centerX = 0.5f, float centerY = 0.5f, float speedMult = 1.0f)
|
||||
{
|
||||
float pct = Math.Clamp((mUpdateCnt - 50 - updateOffset) * 0.25f * speedMult, 0, 1.0f);
|
||||
//float pct = Math.Clamp((mUpdateCnt - 50 - updateOffset) * 0.02f, 0, 1.0f);
|
||||
if (pct == 0)
|
||||
{
|
||||
widget.SetVisible(false);
|
||||
return;
|
||||
}
|
||||
widget.SetVisible(true);
|
||||
if (pct == 1)
|
||||
{
|
||||
widget.ClearTransform();
|
||||
return;
|
||||
}
|
||||
|
||||
Matrix matrix = .IdentityMatrix;
|
||||
matrix.Translate(-widget.mWidth * centerX, -widget.mHeight * centerY);
|
||||
matrix.Scale(pct, pct);
|
||||
matrix.Translate(widget.mWidth * centerX, widget.mHeight * centerY);
|
||||
matrix.Translate(widget.mX, widget.mY);
|
||||
widget.Transform = matrix;
|
||||
}
|
||||
|
||||
void ResizeComponents()
|
||||
{
|
||||
float headerWidth = mHeaderLabel.CalcWidth();
|
||||
mHeaderLabel.Resize(cBodyX + 375 - headerWidth/2, cBodyY + 60, headerWidth, 60);
|
||||
UpdateComponent(mHeaderLabel, 0, 0.5f, 2.0f, 0.4f);
|
||||
|
||||
mCloseButton.Resize(cBodyX + 660, cBodyY + 55, mCloseButton.mImage.mWidth, mCloseButton.mImage.mHeight);
|
||||
UpdateComponent(mCloseButton, 5);
|
||||
|
||||
mInstallForAllCheckbox.Resize(cBodyX + 120, cBodyY + 136, 48, 48);
|
||||
UpdateComponent(mInstallForAllCheckbox, 10);
|
||||
|
||||
mAddToStartCheckbox.Resize(cBodyX + 418, cBodyY + 136, 48, 48);
|
||||
UpdateComponent(mAddToStartCheckbox, 12);
|
||||
|
||||
mAddToDesktopCheckbox.Resize(cBodyX + 120, cBodyY + 190, 48, 48);
|
||||
UpdateComponent(mAddToDesktopCheckbox, 14);
|
||||
|
||||
mStartAfterCheckbox.Resize(cBodyX + 418, cBodyY + 190, 48, 48);
|
||||
UpdateComponent(mStartAfterCheckbox, 16);
|
||||
|
||||
if (!mInstalling)
|
||||
{
|
||||
mInstallPathBox.Resize(cBodyX + 122, cBodyY + 276, 508, Images.sTextBox.mHeight);
|
||||
UpdateComponent(mInstallPathBox, 5, 0.1f, 0.5f, 0.4f);
|
||||
}
|
||||
|
||||
mCancelButton.Resize(cBodyX + 180, cBodyY + 320, mCancelButton.mImage.mWidth, mCancelButton.mImage.mHeight);
|
||||
UpdateComponent(mCancelButton, 13, 0.5f, 0.2f);
|
||||
|
||||
mInstallButton.Resize(cBodyX + 404, cBodyY + 320, mInstallButton.mImage.mWidth, mInstallButton.mImage.mHeight);
|
||||
UpdateComponent(mInstallButton, 15, 0.5f, 0.2f);
|
||||
}
|
||||
|
||||
public override void Resize(float x, float y, float width, float height)
|
||||
{
|
||||
base.Resize(x, y, width, height);
|
||||
ResizeComponents();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -15,14 +15,17 @@ namespace BIStubUI
|
|||
Debug.WriteLine("Deinitializing StubUI");
|
||||
}
|
||||
|
||||
[Export]
|
||||
[Export, CLink]
|
||||
public static void Start(BIApp.InstallFunc installFunc, BIApp.ProgressFunc progressFunc, BIApp.CancelFunc cancelFunc)
|
||||
{
|
||||
gApp = new BIApp();
|
||||
gApp.mInstallFunc = installFunc;
|
||||
gApp.mProgressFunc = progressFunc;
|
||||
gApp.mCancelFunc = cancelFunc;
|
||||
gApp.Init();
|
||||
gApp.Run();
|
||||
gApp.Shutdown();
|
||||
DeleteAndNullify!(gApp);
|
||||
}
|
||||
|
||||
public static void Hello()
|
||||
|
|
102
BeefTools/BeefInstall/StubUI/src/Resources.bf
Normal file
102
BeefTools/BeefInstall/StubUI/src/Resources.bf
Normal file
|
@ -0,0 +1,102 @@
|
|||
using System;
|
||||
using Beefy.gfx;
|
||||
using System.Collections.Generic;
|
||||
using Beefy.sound;
|
||||
|
||||
namespace BIStubUI
|
||||
{
|
||||
class Images
|
||||
{
|
||||
public static Image sBody;
|
||||
public static Image sHead;
|
||||
public static Image sEyesOpen;
|
||||
public static Image sEyesClosed;
|
||||
public static Image sButton;
|
||||
public static Image sButtonHi;
|
||||
public static Image sSmButton;
|
||||
public static Image sClose;
|
||||
public static Image sCloseHi;
|
||||
public static Image sChecked;
|
||||
public static Image sUnchecked;
|
||||
public static Image sTextBox;
|
||||
public static Image sBrowse;
|
||||
public static Image sBrowseDown;
|
||||
public static Image sPBBarBottom;
|
||||
public static Image sPBBarEmpty;
|
||||
public static Image sPBBarHilite;
|
||||
public static Image sPBFrameGlow;
|
||||
public static Image sPBFrameTop;
|
||||
|
||||
static List<Image> sImages = new .() ~ delete _;
|
||||
|
||||
public static Result<Image> Load(String fileName, bool additive = false)
|
||||
{
|
||||
let image = Image.LoadFromFile(scope String(gApp.mInstallDir, "/", fileName), additive);
|
||||
if (image == null)
|
||||
{
|
||||
delete image;
|
||||
return .Err;
|
||||
}
|
||||
sImages.Add(image);
|
||||
return image;
|
||||
}
|
||||
|
||||
public static void Dispose()
|
||||
{
|
||||
ClearAndDeleteItems(sImages);
|
||||
}
|
||||
|
||||
public static Result<void> Init()
|
||||
{
|
||||
sBody = Try!(Load("images/body.png"));
|
||||
sHead = Try!(Load("images/head.png"));
|
||||
sEyesOpen = Try!(Load("images/eyesopen.png"));
|
||||
sEyesClosed = Try!(Load("images/eyesclosed.png"));
|
||||
sButton = Try!(Load("images/button.png"));
|
||||
sButtonHi = Try!(Load("images/button_hi.png"));
|
||||
sSmButton = Try!(Load("images/smbutton.png"));
|
||||
sClose = Try!(Load("images/close.png"));
|
||||
sCloseHi = Try!(Load("images/close_hi.png"));
|
||||
sChecked = Try!(Load("images/checked.png"));
|
||||
sUnchecked = Try!(Load("images/unchecked.png"));
|
||||
sTextBox = Try!(Load("images/textbox.png"));
|
||||
sBrowse = Try!(Load("images/browse.png"));
|
||||
sBrowseDown = Try!(Load("images/browsedown.png"));
|
||||
sPBBarBottom = Try!(Load("images/pb_barbottom.png"));
|
||||
sPBBarEmpty = Try!(Load("images/pb_barempty.png"));
|
||||
sPBBarHilite = Try!(Load("images/pb_barhilite.png", true));
|
||||
sPBFrameGlow = Try!(Load("images/pb_frameglow.png"));
|
||||
sPBFrameTop = Try!(Load("images/pb_frametop.png"));
|
||||
return .Ok;
|
||||
}
|
||||
}
|
||||
|
||||
class Sounds
|
||||
{
|
||||
public static SoundSource sBoing;
|
||||
public static SoundSource sEating;
|
||||
public static SoundSource sButtonPress;
|
||||
public static SoundSource sMouseOver;
|
||||
public static SoundSource sAbort;
|
||||
public static SoundSource sChecked;
|
||||
|
||||
public static Result<SoundSource> Load(String fileName)
|
||||
{
|
||||
let source = gApp.mSoundManager.LoadSound(scope String(gApp.mInstallDir, "/", fileName));
|
||||
if (source.IsInvalid)
|
||||
return .Err;
|
||||
return source;
|
||||
}
|
||||
|
||||
public static Result<void> Init()
|
||||
{
|
||||
sBoing = Try!(Load("sounds/boing.wav"));
|
||||
sEating = Try!(Load("sounds/eating.wav"));
|
||||
sButtonPress = Try!(Load("sounds/buttonpress.wav"));
|
||||
sMouseOver = Try!(Load("sounds/mouseover.wav"));
|
||||
sAbort = Try!(Load("sounds/abort.wav"));
|
||||
sChecked = Try!(Load("sounds/checked.wav"));
|
||||
return .Ok;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue