mirror of
https://github.com/beefytech/Beef.git
synced 2025-07-04 23:36:00 +02:00
UpdateF, dx reinit
This commit is contained in:
parent
fa2cb7ba56
commit
e87bf5b029
24 changed files with 1029 additions and 415 deletions
|
@ -45,7 +45,8 @@ namespace Beefy
|
|||
#endif
|
||||
{
|
||||
public delegate void UpdateDelegate(bool batchStart);
|
||||
public delegate void DrawDelegate();
|
||||
public delegate void UpdateFDelegate(float updatePct);
|
||||
public delegate void DrawDelegate(bool forceDraw);
|
||||
|
||||
public static BFApp sApp;
|
||||
public int32 mUpdateCnt;
|
||||
|
@ -106,7 +107,7 @@ namespace Beefy
|
|||
static extern void BFApp_Shutdown();
|
||||
|
||||
[CallingConvention(.Stdcall), CLink]
|
||||
static extern void BFApp_SetCallbacks(void* updateDelegate, void* drawDelegate);
|
||||
static extern void BFApp_SetCallbacks(void* updateDelegate, void* updateFDelegate, void* drawDelegate);
|
||||
|
||||
[CallingConvention(.Stdcall), CLink]
|
||||
static extern char8* BFApp_GetInstallDir();
|
||||
|
@ -132,7 +133,11 @@ namespace Beefy
|
|||
[CallingConvention(.Stdcall), CLink]
|
||||
public static extern void* BFApp_GetSoundManager();
|
||||
|
||||
[CallingConvention(.Stdcall), CLink]
|
||||
public static extern int BFApp_GetCriticalThreadId(int32 idx);
|
||||
|
||||
UpdateDelegate mUpdateDelegate ~ delete _;
|
||||
UpdateFDelegate mUpdateFDelegate ~ delete _;
|
||||
DrawDelegate mDrawDelegate ~ delete _;
|
||||
|
||||
#if STUDIO_CLIENT
|
||||
|
@ -165,9 +170,9 @@ namespace Beefy
|
|||
}
|
||||
#endif
|
||||
|
||||
static void Static_Draw()
|
||||
static void Static_Draw(bool forceDraw)
|
||||
{
|
||||
sApp.Draw();
|
||||
sApp.Draw(forceDraw);
|
||||
}
|
||||
|
||||
static void Static_Update(bool batchStart)
|
||||
|
@ -175,6 +180,11 @@ namespace Beefy
|
|||
sApp.Update(batchStart);
|
||||
}
|
||||
|
||||
static void Static_UpdateF(float updatePct)
|
||||
{
|
||||
sApp.UpdateF(updatePct);
|
||||
}
|
||||
|
||||
float mLastUpdateDelta; // In seconds
|
||||
|
||||
public this()
|
||||
|
@ -198,9 +208,10 @@ namespace Beefy
|
|||
BFApp_SetRefreshRate(mRefreshRate);
|
||||
|
||||
mUpdateDelegate = new => Static_Update;
|
||||
mDrawDelegate = new => Static_Draw;
|
||||
mUpdateFDelegate = new => Static_UpdateF;
|
||||
mDrawDelegate = new => Static_Draw;
|
||||
#endif
|
||||
BFApp_SetCallbacks(mUpdateDelegate.GetFuncPtr(), mDrawDelegate.GetFuncPtr());
|
||||
BFApp_SetCallbacks(mUpdateDelegate.GetFuncPtr(), mUpdateFDelegate.GetFuncPtr(), mDrawDelegate.GetFuncPtr());
|
||||
}
|
||||
|
||||
#if STUDIO_CLIENT
|
||||
|
@ -515,6 +526,14 @@ namespace Beefy
|
|||
structuredData.Load(resFileName);
|
||||
mResourceManager.ParseConfigData(structuredData);
|
||||
}
|
||||
|
||||
for (int32 i = 0; true; i++)
|
||||
{
|
||||
int threadId = BFApp_GetCriticalThreadId(i);
|
||||
if (threadId == 0)
|
||||
break;
|
||||
GC.ExcludeThreadId(threadId);
|
||||
}
|
||||
}
|
||||
|
||||
public void InitGraphics()
|
||||
|
@ -671,6 +690,14 @@ namespace Beefy
|
|||
//Utils.BFRT_CPP("gBFGC.MutatorSectionExit()");
|
||||
}
|
||||
|
||||
public virtual void UpdateF(float updatePct)
|
||||
{
|
||||
for (int32 windowIdx = 0; windowIdx < mWindows.Count; windowIdx++)
|
||||
{
|
||||
mWindows[windowIdx].UpdateF(updatePct);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void DoDraw()
|
||||
{
|
||||
}
|
||||
|
@ -695,12 +722,11 @@ namespace Beefy
|
|||
}
|
||||
#endif
|
||||
|
||||
public virtual void Draw()
|
||||
public virtual void Draw(bool forceDraw)
|
||||
{
|
||||
#if STUDIO_CLIENT
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
PerfTimer.ZoneStart("BFApp.Draw");
|
||||
PerfTimer.Message("Client Draw Start");
|
||||
|
||||
|
@ -716,7 +742,8 @@ namespace Beefy
|
|||
|
||||
for (BFWindow window in mWindows)
|
||||
{
|
||||
if ((window.mVisible) && ((window.mIsDirty) || (mAutoDirty)))
|
||||
if ((window.mVisible) &&
|
||||
((window.mIsDirty) || (mAutoDirty) || (forceDraw)))
|
||||
{
|
||||
window.PreDraw(mGraphics);
|
||||
if (mColorMatrix != null)
|
||||
|
|
|
@ -664,6 +664,11 @@ namespace Beefy
|
|||
public virtual void Update()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void UpdateF(float updatePct)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
#else
|
||||
public class BFWindow : BFWindowBase, IStudioClientWindow
|
||||
|
|
|
@ -18,7 +18,12 @@ namespace Beefy.theme.dark
|
|||
public bool mIsOpen;
|
||||
public bool mAllowOpen = true;
|
||||
public bool mIsReversed;
|
||||
|
||||
|
||||
public this()
|
||||
{
|
||||
mAlwaysUpdateF = true;
|
||||
}
|
||||
|
||||
public override void Draw(Graphics g)
|
||||
{
|
||||
base.Draw(g);
|
||||
|
@ -52,9 +57,9 @@ namespace Beefy.theme.dark
|
|||
mRot = mIsOpen ? (Math.PI_f / 2) : 0;
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
public override void UpdateF(float updatePct)
|
||||
{
|
||||
base.Update();
|
||||
base.UpdateF(updatePct);
|
||||
|
||||
int childCount = mItem.mChildItems.Count;
|
||||
|
||||
|
@ -62,15 +67,17 @@ namespace Beefy.theme.dark
|
|||
|
||||
if ((mIsOpen) && (mRot < Math.PI_f / 2))
|
||||
{
|
||||
mRot = Math.Min(Math.PI_f / 2, mRot + rotSpeed);
|
||||
mRot = Math.Min(Math.PI_f / 2, mRot + rotSpeed * updatePct);
|
||||
mItem.mListView.mListSizeDirty = true;
|
||||
MarkDirty();
|
||||
mWidgetWindow.mTempWantsUpdateF = true;
|
||||
}
|
||||
else if ((!mIsOpen) && (mRot > 0))
|
||||
{
|
||||
mRot = (float)Math.Max(0, mRot - rotSpeed);
|
||||
mRot = (float)Math.Max(0, mRot - rotSpeed * updatePct);
|
||||
mItem.mListView.mListSizeDirty = true;
|
||||
MarkDirty();
|
||||
mWidgetWindow.mTempWantsUpdateF = true;
|
||||
}
|
||||
|
||||
float x;
|
||||
|
@ -876,6 +883,25 @@ namespace Beefy.theme.dark
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void UpdateFAll(float updatePct)
|
||||
{
|
||||
if (mVisible)
|
||||
{
|
||||
base.UpdateFAll(updatePct);
|
||||
|
||||
if (mChildItems != null)
|
||||
{
|
||||
for (int32 anIdx = 0; anIdx < mChildItems.Count; anIdx++)
|
||||
{
|
||||
Widget child = mChildItems[anIdx];
|
||||
Debug.Assert(child.mParent == this);
|
||||
Debug.Assert(child.mWidgetWindow == mWidgetWindow);
|
||||
child.UpdateFAll(updatePct);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class DarkListView : ListView
|
||||
|
|
|
@ -37,9 +37,9 @@ namespace Beefy.utils
|
|||
get { return mPct != 1.0f; }
|
||||
}
|
||||
|
||||
public void Update()
|
||||
public void Update(float updatePct = 1.0f)
|
||||
{
|
||||
mPct = Math.Min(1.0f, mPct + mSpeed * mSpeedScale);
|
||||
mPct = Math.Min(1.0f, mPct + mSpeed * mSpeedScale * updatePct);
|
||||
}
|
||||
|
||||
public void Set(double val, bool immediate = false)
|
||||
|
|
|
@ -788,10 +788,15 @@ namespace Beefy.widgets
|
|||
public override void UpdateAll()
|
||||
{
|
||||
base.UpdateAll();
|
||||
|
||||
UpdateListSize();
|
||||
}
|
||||
|
||||
public override void UpdateFAll(float updatePct)
|
||||
{
|
||||
base.UpdateFAll(updatePct);
|
||||
UpdateListSize();
|
||||
}
|
||||
|
||||
public virtual float GetListWidth()
|
||||
{
|
||||
float columnWidths = 0;
|
||||
|
@ -802,7 +807,7 @@ namespace Beefy.widgets
|
|||
|
||||
public void UpdateListSize()
|
||||
{
|
||||
// Do this in UpdateAll to give children a change to resize items
|
||||
// Do this in UpdateAll to give children a chance to resize items
|
||||
if (mListSizeDirty)
|
||||
{
|
||||
float listWidth = GetListWidth();
|
||||
|
|
|
@ -50,6 +50,7 @@ namespace Beefy.widgets
|
|||
mScrollContentContainer.mClipGfx = true;
|
||||
mScrollContentContainer.mClipMouse = true;
|
||||
AddWidget(mScrollContentContainer);
|
||||
mAlwaysUpdateF = true;
|
||||
}
|
||||
|
||||
public ~this()
|
||||
|
@ -248,15 +249,23 @@ namespace Beefy.widgets
|
|||
{
|
||||
base.Update();
|
||||
|
||||
if ((mHorzPos.IsMoving) || (mVertPos.IsMoving))
|
||||
{
|
||||
mHorzPos.Update();
|
||||
mVertPos.Update();
|
||||
UpdateContentPosition();
|
||||
MarkDirty();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateF(float updatePct)
|
||||
{
|
||||
base.UpdateF(updatePct);
|
||||
|
||||
if ((mHorzPos.IsMoving) || (mVertPos.IsMoving))
|
||||
{
|
||||
mWidgetWindow.mTempWantsUpdateF = true;
|
||||
mHorzPos.Update(updatePct);
|
||||
mVertPos.Update(updatePct);
|
||||
UpdateContentPosition();
|
||||
MarkDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public override void MouseWheel(float x, float y, float deltaX, float deltaY)
|
||||
{
|
||||
base.MouseWheel(x, y, deltaX, deltaY);
|
||||
|
|
|
@ -39,6 +39,7 @@ namespace Beefy.widgets
|
|||
public float mWidth;
|
||||
public float mHeight;
|
||||
public int32 mUpdateCnt;
|
||||
public double mUpdateCntF;
|
||||
public String mIdStr ~ delete _;
|
||||
public List<Widget> mChildWidgets;
|
||||
public MouseFlag mMouseFlags;
|
||||
|
@ -56,6 +57,7 @@ namespace Beefy.widgets
|
|||
public bool mDeferredDelete;
|
||||
public Insets mMouseInsets ~ delete _;
|
||||
public bool mAutoFocus;
|
||||
public bool mAlwaysUpdateF;
|
||||
|
||||
public float X { get { return mX; } set { mX = value; } }
|
||||
public float Y { get { return mY; } set { mY = value; } }
|
||||
|
@ -455,8 +457,16 @@ namespace Beefy.widgets
|
|||
public virtual void Update()
|
||||
{
|
||||
mUpdateCnt++;
|
||||
if ((mAlwaysUpdateF) && (mWidgetWindow != null))
|
||||
UpdateF((float)(mUpdateCnt - mUpdateCntF));
|
||||
mUpdateCntF = mUpdateCnt;
|
||||
}
|
||||
|
||||
public virtual void UpdateF(float updatePct)
|
||||
{
|
||||
mUpdateCntF += updatePct;
|
||||
}
|
||||
|
||||
public void DeferDelete()
|
||||
{
|
||||
mDeferredDelete = true;
|
||||
|
@ -487,6 +497,31 @@ namespace Beefy.widgets
|
|||
}
|
||||
}
|
||||
|
||||
public virtual void UpdateFAll(float updatePct)
|
||||
{
|
||||
UpdateF(updatePct);
|
||||
if (mDeferredDelete)
|
||||
{
|
||||
delete this;
|
||||
return;
|
||||
}
|
||||
|
||||
// Removed self?
|
||||
if (mWidgetWindow == null)
|
||||
return;
|
||||
|
||||
if (mChildWidgets != null)
|
||||
{
|
||||
for (int32 anIdx = 0; anIdx < mChildWidgets.Count; anIdx++)
|
||||
{
|
||||
Widget child = mChildWidgets[anIdx];
|
||||
Debug.Assert(child.mParent == this);
|
||||
Debug.Assert(child.mWidgetWindow == mWidgetWindow);
|
||||
child.UpdateFAll(updatePct);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Resize(float x, float y, float width, float height)
|
||||
{
|
||||
Debug.Assert(width >= 0);
|
||||
|
|
|
@ -62,6 +62,8 @@ namespace Beefy.widgets
|
|||
public bool mHasMouseInside;
|
||||
public bool mHasProxyMouseInside;
|
||||
public bool mIsKeyDownHandled;
|
||||
public bool mWantsUpdateF;
|
||||
public bool mTempWantsUpdateF;
|
||||
|
||||
public int32 mContentClientWidth;
|
||||
public int32 mContentClientHeight;
|
||||
|
@ -153,8 +155,18 @@ namespace Beefy.widgets
|
|||
return;
|
||||
base.Update();
|
||||
RehupMouse(false);
|
||||
mTempWantsUpdateF = false;
|
||||
mRootWidget.UpdateAll();
|
||||
}
|
||||
|
||||
public override void UpdateF(float updatePct)
|
||||
{
|
||||
if (mRootWidget == null)
|
||||
return;
|
||||
base.Update();
|
||||
if (mWantsUpdateF || mTempWantsUpdateF)
|
||||
mRootWidget.UpdateFAll(updatePct);
|
||||
}
|
||||
|
||||
public override int32 CloseQuery()
|
||||
{
|
||||
|
|
|
@ -133,6 +133,8 @@ namespace System
|
|||
public extern static void SetMaxPausePercentage(int maxPausePercentage); // 0 = disabled. Defaults to 20.
|
||||
[CallingConvention(.Cdecl)]
|
||||
extern static void AddPendingThread(void* internalThread);
|
||||
[CallingConvention(.Cdecl)]
|
||||
public extern static void ExcludeThreadId(int thereadId);
|
||||
#else
|
||||
public static void Collect(bool async = true) {}
|
||||
private static void MarkAllStaticMembers() {}
|
||||
|
@ -144,6 +146,7 @@ namespace System
|
|||
public static void SetCollectFreeThreshold(int freeBytes) {}
|
||||
public static void SetMaxPausePercentage(int maxPausePercentage) {}
|
||||
static void AddPendingThread(void* internalThreadInfo) {}
|
||||
public static void ExcludeThreadId(int thereadId) {}
|
||||
#endif
|
||||
|
||||
static void MarkDerefedObject(Object* obj)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue