1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 19:48:20 +02:00

Moved BeefInstall to Beef_website

This commit is contained in:
Brian Fiete 2019-09-07 06:39:26 -07:00
parent d7da98444e
commit faa1dbd45e
18 changed files with 0 additions and 1659 deletions

View file

@ -1,26 +0,0 @@
FileVersion = 1
[Project]
Name = "Stub"
TargetType = "BeefWindowsApplication"
StartupObject = "BIStub.Program"
[Configs.Debug.Win64]
TargetDirectory = "$(WorkspaceDir)/../dist"
TargetName = "$(ProjectName)_d"
BeefLibType = "Static"
[Configs.Release.Win64]
TargetDirectory = "$(WorkspaceDir)/../dist"
[Configs.Paranoid.Win64]
TargetDirectory = "$(WorkspaceDir)/../dist"
[Configs.Test.Win64]
TargetDirectory = "$(WorkspaceDir)/../dist"
[ProjectFolder]
[[ProjectFolder.Items]]
Type = "Source"
Path = "../../../IDE/src/util/Zip.bf"

View file

@ -1,11 +0,0 @@
FileVersion = 1
Projects = {Stub = {Path = "."}}
Unlocked = ["corlib"]
[Workspace]
StartupProject = "Stub"
[Configs.Debug.Win64]
AllocType = "CRT"
EnableObjectDebugFlags = false
IntermediateType = "ObjectAndIRCode"

View file

@ -1,278 +0,0 @@
using System;
using System.IO;
namespace System.Windows
{
class CabFile
{
struct HFDI : int
{
}
struct HFile : int
{
}
enum FDIERROR : int32
{
FDIERROR_NONE,
FDIERROR_CABINET_NOT_FOUND,
FDIERROR_NOT_A_CABINET,
FDIERROR_UNKNOWN_CABINET_VERSION,
FDIERROR_CORRUPT_CABINET,
FDIERROR_ALLOC_FAIL,
FDIERROR_BAD_COMPR_TYPE,
FDIERROR_MDI_FAIL,
FDIERROR_TARGET_FILE,
FDIERROR_RESERVE_MISMATCH,
FDIERROR_WRONG_CABINET,
FDIERROR_USER_ABORT,
FDIERROR_EOF,
}
[CRepr]
struct FDICABINETINFO
{
public int32 cbCabinet; // Total length of cabinet file
public uint16 cFolders; // Count of folders in cabinet
public uint16 cFiles; // Count of files in cabinet
public uint16 setID; // Cabinet set ID
public uint16 iCabinet; // Cabinet number in set (0 based)
public Windows.IntBool fReserve; // TRUE => RESERVE present in cabinet
public Windows.IntBool hasprev; // TRUE => Cabinet is chained prev
public Windows.IntBool hasnext; // TRUE => Cabinet is chained next
}
[CRepr]
struct FDINOTIFICATION
{
public int32 cb;
public char8* psz1;
public char8* psz2;
public char8* psz3; // Points to a 256 character buffer
public void* pv; // Value for client
public HFile hf;
public uint16 date;
public uint16 time;
public uint16 attribs;
public uint16 setID; // Cabinet set ID
public uint16 iCabinet; // Cabinet number (0-based)
public uint16 iFolder; // Folder number (0-based)
public FDIERROR fdie;
}
enum NotificationType : int32
{
CABINET_INFO, // General information about cabinet
PARTIAL_FILE, // First file in cabinet is continuation
COPY_FILE, // File to be copied
CLOSE_FILE_INFO, // close the file, set relevant info
NEXT_CABINET, // File continued to next cabinet
ENUMERATE, // Enumeration status
}
struct ERF
{
public int32 erfOper; // FCI/FDI error code -- see FDIERROR_XXX
// and FCIERR_XXX equates for details.
public int32 erfType; // Optional error value filled in by FCI/FDI.
// For FCI, this is usually the C run-time
// *errno* value.
public Windows.IntBool fError; // TRUE => error present
}
enum FDIDECRYPTTYPE : int32
{
NEW_CABINET, // New cabinet
NEW_FOLDER, // New folder
DECRYPT, // Decrypt a data block
}
[CRepr]
struct FDIDECRYPT
{
public FDIDECRYPTTYPE fdidt; // Command type (selects union below)
public void* pvUser; // Decryption context
}
[CRepr]
struct FDIDECRYPT_CABINET : FDIDECRYPT
{
public void* pHeaderReserve; // RESERVE section from CFHEADER
public uint16 cbHeaderReserve; // Size of pHeaderReserve
public uint16 setID; // Cabinet set ID
public int32 iCabinet; // Cabinet number in set (0 based)
}
[CRepr]
struct FDIDECRYPT_FOLDER : FDIDECRYPT
{
public void* pFolderReserve; // RESERVE section from CFFOLDER
public uint16 cbFolderReserve; // Size of pFolderReserve
public uint16 iFolder; // Folder number in cabinet (0 based)
}
[CRepr]
struct FDIDECRYPT_DECRYPT : FDIDECRYPT
{
public void* pDataReserve; // RESERVE section from CFDATA
public uint16 cbDataReserve; // Size of pDataReserve
public void* pbData; // Data buffer
public uint16 cbData; // Size of data buffer
public Windows.IntBool fSplit; // TRUE if this is a split data block
public uint16 cbPartial; // 0 if this is not a split block, or
// the first piece of a split block;
// Greater than 0 if this is the
// second piece of a split block.
}
function void* FNALLOC(uint32 cb);
function void FNFREE(void* p);
function HFile FNOPEN(char8* fileName, int32 oflag, int32 pmode);
function uint32 FNREAD(HFile file, void* pv, uint32 cb);
function uint32 FNWRITE(HFile file, void* pv, uint32 cb);
function int32 FNCLOSE(HFile file);
function int32 FNSEEK(HFile file, int32 dist, int32 seekType);
function int FNFDINOTIFY(NotificationType notifyType, FDINOTIFICATION* notifyData);
function int32 FNFDIDECRYPT(FDIDECRYPT* fdid);
static void* CabMemAlloc(uint32 cb)
{
return new uint8[cb]*;
}
static void CabMemFree(void* p)
{
delete p;
}
static HFile CabFileOpen(char8* fileName, int32 oflag, int32 pmode)
{
String fileNameStr = scope .(fileName);
Windows.Handle fh;
if (oflag & 0x0100 != 0)
{
// Creating
fh = Windows.CreateFileW(fileNameStr.ToScopedNativeWChar!(), Windows.GENERIC_READ | Windows.GENERIC_WRITE, .Read | .Write, null, .Create, 0, .NullHandle);
}
else
{
// Reading
fh = Windows.CreateFileW(fileNameStr.ToScopedNativeWChar!(), Windows.GENERIC_READ, .Read | .Write, null, .Open, 0, .NullHandle);
}
return (.)fh;
}
static uint32 CabFileRead(HFile file, void* pv, uint32 cb)
{
Windows.ReadFile((.)file, (.)pv, (.)cb, var bytesRead, null);
return (.)bytesRead;
}
static uint32 CabFileWrite(HFile file, void* pv, uint32 cb)
{
Windows.WriteFile((.)file, (.)pv, (.)cb, var bytesWritten, null);
return (.)bytesWritten;
}
static int32 CabFileClose(HFile file)
{
((Windows.Handle)file).Close();
return 0;
}
static int32 CabFileSeek(HFile file, int32 dist, int32 seekType)
{
return Windows.SetFilePointer((.)file, dist, null, seekType);
}
static int CabFDINotify(NotificationType notifyType, FDINOTIFICATION* notifyData)
{
if (notifyType == .COPY_FILE)
{
String destFileName = scope .();
destFileName.Append(@"c:\temp\out\");
destFileName.Append(notifyData.psz1);
//_O_BINARY | _O_CREAT | _O_WRONLY | _O_SEQUENTIAL
//_S_IREAD | _S_IWRITE
String dirPath = scope String();
Path.GetDirectoryPath(destFileName, dirPath);
Directory.CreateDirectory(dirPath).IgnoreError();
let hOutFile = CabFileOpen(destFileName, 0x8121, 0x0180);
return (.)hOutFile;
}
else if (notifyType == .CLOSE_FILE_INFO)
{
CabFileClose(notifyData.hf);
return 1;
}
return 0;
}
[Import("Cabinet.lib"), CLink]
static extern HFDI FDICreate(FNALLOC pfnalloc,
FNFREE pfnfree,
FNOPEN pfnopen,
FNREAD pfnread,
FNWRITE pfnwrite,
FNCLOSE pfnclose,
FNSEEK pfnseek,
int32 cpuType,
ERF* erf);
[CLink]
static extern Windows.IntBool FDIDestroy(HFDI hfdi);
[CLink]
static extern Windows.IntBool FDICopy(HFDI hfdi,
char8* pszCabinet,
char8* pszCabPath,
int32 flags,
FNFDINOTIFY fnfdin,
FNFDIDECRYPT pfnfdid,
void* pvUser);
HFDI mHDFI;
public ~this()
{
if (mHDFI != 0)
{
FDIDestroy(mHDFI);
}
}
public void Init()
{
ERF erf;
mHDFI = FDICreate(=> CabMemAlloc,
=> CabMemFree,
=> CabFileOpen,
=> CabFileRead,
=> CabFileWrite,
=> CabFileClose,
=> CabFileSeek,
1 /*cpu80386*/,
&erf);
}
public void Copy()
{
FDICopy(mHDFI, "test.cab", "c:\\temp\\", 0, => CabFDINotify, null, Internal.UnsafeCastToPtr(this));
}
}
}

View file

@ -1,236 +0,0 @@
using System;
namespace System.Windows
{
class PEFile
{
public const uint16 PE_MACHINE_X86 = 0x14c;
public const uint16 PE_MACHINE_X64 = 0x8664;
[CRepr]
public struct PEHeader
{
public uint16 e_magic; // Magic number
public uint16 e_cblp; // uint8s on last page of file
public uint16 e_cp; // Pages in file
public uint16 e_crlc; // Relocations
public uint16 e_cparhdr; // Size of header in paragraphs
public uint16 e_minalloc; // Minimum extra paragraphs needed
public uint16 e_maxalloc; // Maximum extra paragraphs needed
public uint16 e_ss; // Initial (relative) SS value
public uint16 e_sp; // Initial SP value
public uint16 e_csum; // Checksum
public uint16 e_ip; // Initial IP value
public uint16 e_cs; // Initial (relative) CS value
public uint16 e_lfarlc; // File address of relocation table
public uint16 e_ovno; // Overlay number
public uint16[4] e_res; // Reserved uint16s
public uint16 e_oemid; // OEM identifier (for e_oeminfo)
public uint16 e_oeminfo; // OEM information; e_oemid specific
public uint16[10] e_res2; // Reserved uint16s
public int32 e_lfanew; // File address of new exe header
};
[CRepr]
public struct PEFileHeader
{
public uint16 mMachine;
public uint16 mNumberOfSections;
public uint32 mTimeDateStamp;
public uint32 mPointerToSymbolTable;
public uint32 mNumberOfSymbols;
public uint16 mSizeOfOptionalHeader;
public uint16 mCharacteristics;
};
[CRepr]
public struct PEImportObjectHeader
{
public uint16 mSig1;
public uint16 mSig2;
public uint16 mVersion;
public uint16 mMachine;
public uint32 mTimeDateStamp;
public uint32 mDataSize;
public uint16 mHint;
public uint16 mType;
};
[CRepr]
public struct PEDataDirectory
{
public uint32 mVirtualAddress;
public uint32 mSize;
};
[CRepr]
public struct PEOptionalHeader32
{
//
// Standard fields.
//
public uint16 mMagic;
public uint8 mMajorLinkerVersion;
public uint8 mMinorLinkerVersion;
public uint32 mSizeOfCode;
public uint32 mSizeOfInitializedData;
public uint32 mSizeOfUninitializedData;
public uint32 mAddressOfEntryPoint;
public uint32 mBaseOfCode;
public uint32 mBaseOfData;
//
// NT additional fields.
//
public uint32 mImageBase;
public uint32 mSectionAlignment;
public uint32 mFileAlignment;
public uint16 mMajorOperatingSystemVersion;
public uint16 mMinorOperatingSystemVersion;
public uint16 mMajorImageVersion;
public uint16 mMinorImageVersion;
public uint16 mMajorSubsystemVersion;
public uint16 mMinorSubsystemVersion;
public uint32 mReserved1;
public uint32 mSizeOfImage;
public uint32 mSizeOfHeaders;
public uint32 mCheckSum;
public uint16 mSubsystem;
public uint16 mDllCharacteristics;
public uint32 mSizeOfStackReserve;
public uint32 mSizeOfStackCommit;
public uint32 mSizeOfHeapReserve;
public uint32 mSizeOfHeapCommit;
public uint32 mLoaderFlags;
public uint32 mNumberOfRvaAndSizes;
public PEDataDirectory[16] mDataDirectory;
};
[CRepr]
public struct PEOptionalHeader64
{
//
// Standard fields.
//
public uint16 mMagic;
public uint8 mMajorLinkerVersion;
public uint8 mMinorLinkerVersion;
public uint32 mSizeOfCode;
public uint32 mSizeOfInitializedData;
public uint32 mSizeOfUninitializedData;
public uint32 mAddressOfEntryPoint;
public uint32 mBaseOfCode;
//
// NT additional fields.
//
public uint64 mImageBase;
public uint32 mSectionAlignment;
public uint32 mFileAlignment;
public uint16 mMajorOperatingSystemVersion;
public uint16 mMinorOperatingSystemVersion;
public uint16 mMajorImageVersion;
public uint16 mMinorImageVersion;
public uint16 mMajorSubsystemVersion;
public uint16 mMinorSubsystemVersion;
public uint32 mReserved1;
public uint32 mSizeOfImage;
public uint32 mSizeOfHeaders;
public uint32 mCheckSum;
public uint16 mSubsystem;
public uint16 mDllCharacteristics;
public uint64 mSizeOfStackReserve;
public uint64 mSizeOfStackCommit;
public uint64 mSizeOfHeapReserve;
public uint64 mSizeOfHeapCommit;
public uint32 mLoaderFlags;
public uint32 mNumberOfRvaAndSizes;
public PEDataDirectory[16] mDataDirectory;
};
[CRepr]
struct PE_NTHeaders32
{
uint32 mSignature;
PEFileHeader mFileHeader;
PEOptionalHeader32 mOptionalHeader;
};
[CRepr]
public struct PE_NTHeaders64
{
public uint32 mSignature;
public PEFileHeader mFileHeader;
public PEOptionalHeader64 mOptionalHeader;
};
const int IMAGE_SIZEOF_SHORT_NAME = 8;
[CRepr]
public struct PESectionHeader
{
public char8[IMAGE_SIZEOF_SHORT_NAME] mName;
public uint32 mVirtualSize;
public uint32 mVirtualAddress;
public uint32 mSizeOfRawData;
public uint32 mPointerToRawData;
public uint32 mPointerToRelocations;
public uint32 mPointerToLineNumbers;
public uint16 mNumberOfRelocations;
public uint16 mNumberOfLineNumbers;
public uint32 mCharacteristics;
};
[CRepr]
struct COFFRelocation
{
uint32 mVirtualAddress;
uint32 mSymbolTableIndex;
uint16 mType;
};
[CRepr]
struct PE_SymInfo
{
[Union]
public struct Name
{
public char8[8] mName;
public int32[2] mNameOfs;
}
public Name mName;
/*union
{
char mName[8];
int32 mNameOfs[2];
};*/
public int32 mValue;
public uint16 mSectionNum;
public uint16 mType;
public int8 mStorageClass;
public int8 mNumOfAuxSymbols;
};
[CRepr]
struct PE_SymInfoAux
{
public uint32 mLength;
public uint16 mNumberOfRelocations;
public uint16 mNumberOfLinenumbers;
public uint32 mCheckSum;
public uint16 mNumber;
public uint8 mSelection;
public char8 mUnused;
public char8 mUnused2;
public char8 mUnused3;
};
}
}

View file

@ -1,181 +0,0 @@
using System;
using IDE.Util;
using System.IO;
using System.Windows;
namespace BIStub
{
class Program
{
bool mFailed;
void Fail(StringView str)
{
if (mFailed)
return;
mFailed = true;
Windows.MessageBoxA(default, scope String..AppendF("ERROR: {}", str), "FATAL ERROR", Windows.MB_ICONHAND);
}
bool HandleCommandLineParam(String key, String value)
{
return false;
}
void UnhandledCommandLine(String key, String value)
{
}
void ParseCommandLine(String[] args)
{
for (var str in args)
{
int eqPos = str.IndexOf('=');
if (eqPos == -1)
{
if (!HandleCommandLineParam(str, null))
UnhandledCommandLine(str, null);
}
else
{
var cmd = scope String(str, 0, eqPos);
var param = scope String(str, eqPos + 1);
if (!HandleCommandLineParam(cmd, param))
UnhandledCommandLine(cmd, param);
}
}
}
Result<void> ExtractTo(ZipFile zipFile, StringView destDir, StringView subStr)
{
String fileName = scope .();
String destPath = scope .();
for (int i < zipFile.GetNumFiles())
{
ZipFile.Entry entry = scope .();
if (zipFile.SelectEntry(i, entry) case .Err)
continue;
fileName.Clear();
entry.GetFileName(fileName);
if (!fileName.StartsWith(subStr))
continue;
destPath.Clear();
destPath.Append(destDir);
destPath.Append('/');
destPath.Append(fileName);
if (entry.IsDirectory)
{
if (Directory.CreateDirectory(destPath) case .Err)
return .Err;
}
else
{
if (entry.ExtractToFile(destPath) case .Err)
return .Err;
}
}
return .Ok;
}
void CheckPE()
{
let module = Windows.GetModuleHandleW(null);
uint8* moduleData = (uint8*)(int)module;
PEFile.PEHeader* header = (.)moduleData;
PEFile.PE_NTHeaders64* hdr64 = (.)(moduleData + header.e_lfanew);
if (hdr64.mFileHeader.mMachine == PEFile.PE_MACHINE_X64)
{
int fileEnd = 0;
for (int sectIdx < hdr64.mFileHeader.mNumberOfSections)
{
PEFile.PESectionHeader* sectHdrHead = (.)((uint8*)(hdr64 + 1)) + sectIdx;
fileEnd = Math.Max(fileEnd, sectHdrHead.mPointerToRawData + sectHdrHead.mSizeOfRawData);
}
}
}
public function void InstallFunc(StringView dest, StringView filter);
public function int ProgressFunc();
public function void CancelFunc();
public function void StartFunc(InstallFunc installFunc, ProgressFunc progressFunc, CancelFunc cancelFunc);
static void UI_Install(StringView dest, StringView filter)
{
}
static int UI_GetProgress()
{
return 0;
}
static void UI_Cancel()
{
}
void StartUI(StringView dir)
{
String destLib = scope .();
destLib.Append(dir);
destLib.Append("/../dist/StubUI_d.dll");
var lib = Windows.LoadLibraryW(destLib.ToScopedNativeWChar!());
if (lib.IsInvalid)
{
Fail(scope String()..AppendF("Failed to load installer UI '{}'", destLib));
return;
}
StartFunc startFunc = (.)Windows.GetProcAddress(lib, "Start");
if (startFunc == null)
{
Fail(scope String()..AppendF("Failed to initialize installer UI '{}'", destLib));
return;
}
startFunc(=> UI_Install, => UI_GetProgress, => UI_Cancel);
Windows.FreeLibrary(lib);
}
void Run()
{
String cwd = scope .();
Directory.GetCurrentDirectory(cwd);
StartUI(cwd);
/*CheckPE();
ZipFile zipFile = scope .();
zipFile.Open(@"c:\\temp\\build_1827.zip");
ExtractTo(zipFile, @"c:\temp\unzip", .());
CabFile cabFile = scope .();
cabFile.Init();
cabFile.Copy();*/
}
static int Main(String[] args)
{
Program pg = new Program();
pg.ParseCommandLine(args);
pg.Run();
delete pg;
return 0;
}
}
}

View file

@ -1,24 +0,0 @@
FileVersion = 1
Dependencies = {corlib = "*", Beefy2D = "*", SDL2 = "*"}
[Project]
Name = "StubUI"
TargetType = "BeefDynLib"
StartupObject = "Program"
DefaultNamespace = "BIStubUI"
[Configs.Debug.Win64]
TargetDirectory = "$(WorkspaceDir)/../dist"
TargetName = "$(ProjectName)_d"
OtherLinkFlags = "$(LinkFlags) BeefySysLib64_d.lib"
BeefLibType = "DynamicDebug"
DebugCommand = "$(WorkspaceDir)\\..\\dist\\Stub_d.exe"
[Configs.Release.Win64]
TargetDirectory = "$(WorkspaceDir)/../dist"
[Configs.Paranoid.Win64]
TargetDirectory = "$(WorkspaceDir)/../dist"
[Configs.Test.Win64]
TargetDirectory = "$(WorkspaceDir)/../dist"

View file

@ -1,10 +0,0 @@
FileVersion = 1
Projects = {StubUI = {Path = "."}, Beefy2D = "*", SDL2 = "*"}
Unlocked = ["Beefy2D", "corlib", "SDL2"]
[Workspace]
StartupProject = "StubUI"
[Configs.Debug.Win64]
AllocType = "CRT"
IntermediateType = "ObjectAndIRCode"

File diff suppressed because one or more lines are too long

View file

@ -1,129 +0,0 @@
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;
public Board mBoard;
public Widget mRootWidget;
public WidgetWindow mMainWindow;
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 = .QuitOnClose
| .DestAlpha
;
GetWorkspaceRect(var workX, var workY, var workWidth, var workHeight);
mRootWidget = new Widget();
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();
}
}
static
{
public static BIApp gApp;
}
}

View file

@ -1,619 +0,0 @@
using Beefy.widgets;
using Beefy.geom;
using Beefy.gfx;
using System.Diagnostics;
using System;
using System.IO;
using System.Threading;
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;
int mInstallTicks;
public bool mIsClosed;
bool mUninstallDone;
public bool mInstalling;
public bool mUninstalling;
public float mInstallPct;
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 Uninstall()
{
Thread.Sleep(10000);
mUninstallDone = true;
}
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);
if (mUninstalling)
fillWidth = totalWidth * mInstallPct;
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;
if (gApp.mClosing)
{
colorLeft = 0x80000000;
colorRight = 0x800288E9;
}
g.FillRectGradient(barX, barY, fillWidth, barHeight, colorLeft, colorRight, colorLeft, colorRight);
float barPct = (mInstallTicks % 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 + barPct) * 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 bool IsDecompressing
{
get
{
//return gApp.
return false;
}
}
public override void Update()
{
base.Update();
ResizeComponents();
if (gApp.mClosing)
{
mCancelButton.mDisabled = true;
mCancelButton.mMouseVisible = false;
if ((mInstalling) && (!mUninstallDone))
{
if ((!IsDecompressing) && (!mUninstalling))
{
mUninstalling = true;
ThreadPool.QueueUserWorkItem(new => Uninstall);
}
mInstallTicks--;
if (mInstallTicks < 0)
mInstallTicks = 0x3FFFFFFF;
}
if (mInstallPct > 0)
{
mInstallPct = (mInstallPct * 0.98f) - 0.003f;
if (!mUninstallDone)
mInstallPct = Math.Max(mInstallPct, 0.1f);
return;
}
if ((mInstalling) && (!mUninstallDone))
{
return;
}
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 (mInstalling)
mInstallTicks++;
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();
}
}
}

View file

@ -1,41 +0,0 @@
using System;
using System.Diagnostics;
namespace BIStubUI
{
class Program
{
public static this()
{
Debug.WriteLine("Initializing StubUI");
}
public static ~this()
{
Debug.WriteLine("Deinitializing StubUI");
}
[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()
{
}
public static int Main(String[] args)
{
return 0;
}
}
}

View file

@ -1,102 +0,0 @@
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;
}
}
}