More Steam functionality, less renaming. functions now closely relate to the original function/class/method structure and many helper types have been added native to BlitzSteam (no need for BlitzUtility).

This commit is contained in:
Michael Fabian Dirks
2016-03-04 03:47:32 +01:00
parent 7209e0936e
commit 2bf8361797
67 changed files with 4507 additions and 3109 deletions
+66
View File
@@ -0,0 +1,66 @@
; BlitzSteam - Steam wrapper for Blitz
; Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU Lesser General Public License as
; published by the Free Software Foundation, either version 3 of the
; License, or (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU Lesser General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
Include "../BlitzSteam.bb"
; Initialize Steam before your next call to Graphics.
If BS_Steam_Init() = False Then
RuntimeError "Steam: Failed to initialize!"
EndIf
Const FPS = 30
Const FPS_MULT# = 1.0 / FPS
; Demo Scene
Graphics3D 1024, 768, 32, 2
SetBuffer BackBuffer()
Local tickTimer = CreateTimer(FPS)
Local demoRoot = CreatePivot()
Local demoCameraRoot = CreatePivot(demoRoot)
Local demoCamera = CreateCamera(demoCameraRoot)
MoveEntity demoCamera, 0, 0, -10
Local demoCube = CreateCube(demoRoot)
Local EndGame = False
Repeat
Cls
;! Update
; End on Escape
EndGame = KeyHit(1)
TurnEntity demoCube, 1 * FPS_MULT, 3 * FPS_MULT, 2.332 * FPS_MULT
;! Render 3D
RenderWorld
;! Render 2D
Text 0, 0, "Escape to Quit"
;! Update Window
Flip 0
WaitTimer(demoTimer)
Until EndGame = True
; Shut down Steam as the last action of your program.
BS_Steam_Shutdown()
End
;~IDEal Editor Parameters:
;~C#Blitz3D
+128
View File
@@ -0,0 +1,128 @@
; BlitzSteam - Steam wrapper for Blitz
; Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU Lesser General Public License as
; published by the Free Software Foundation, either version 3 of the
; License, or (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU Lesser General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
Include "../BlitzSteam.bb"
; Initialize Steam before your next call to Graphics.
If BS_Steam_Init() = False Then
RuntimeError "Steam: Failed to initialize!"
EndIf
Const FPS = 30
Const FPS_MULT# = 1.0 / FPS
; Demo Scene
Graphics3D 1024, 768, 32, 2
SetBuffer BackBuffer()
Local demoTimer = CreateTimer(FPS)
Local demoRoot = CreatePivot()
Local demoCameraRoot = CreatePivot(demoRoot)
Local demoCamera = CreateCamera(demoCameraRoot)
MoveEntity demoCamera, 0, 0, -10
Local demoCube = CreateCube(demoRoot)
; SteamAppList stuff
Type SteamAppList
Field AppId%
Field Name$
Field InstallDir$
Field BuildId%
End Type
Global SteamAppList_Count%
Function SteamAppList_Fill()
SteamAppList_Count = BS_AppList_GetNumInstalledApps(BS_AppList())
Local Buffer = CreateBank(4 * SteamAppList_Count)
Local AppNameBuffer = CreateBank(1024)
Local PathBuffer = CreateBank(260)
Local AppIdCount = BS_AppList_GetInstalledApps(BS_AppList(), Buffer, SteamAppList_Count)
Delete Each SteamAppList
For Index = 0 To AppIdCount - 1
Local AppId = PeekInt(Buffer, Index*4)
Local SAL.SteamAppList = New SteamAppList
SAL\AppId = AppId
Local AppNameLen = BS_AppList_GetAppName(BS_AppList(), AppId, AppNameBuffer, 1024)
SAL\Name = PeekCString(AppNameBuffer, 0, AppNameLen)
Local PathLen = BS_AppList_GetAppInstallDir(BS_AppList(), AppId, PathBuffer, 260)
SAL\InstallDir = PeekCString(PathBuffer, 0, PathLen)
SAL\BuildId = BS_AppList_GetAppBuildId(BS_AppList(), AppId)
Next
FreeBank AppNameBuffer
FreeBank PathBuffer
FreeBank Buffer
End Function
Function PeekCString$(Bank, Offset=0, Length=-1)
Local Out$ = "", Pos = Offset
While Abs(Length) > 0
Length = Length - 1
Local by = PeekByte(Bank, Pos)
If by = 0 Then
Length = 0
Else
Out = Out + Chr(by)
EndIf
Pos = Pos + 1
Wend
Return Out
End Function
SteamAppList_Fill()
; Main Loop
Local EndGame = False
Repeat
Cls
;! Update
; End on Escape
EndGame = KeyHit(1)
TurnEntity demoCube, 1 * FPS_MULT, 3 * FPS_MULT, 2.332 * FPS_MULT
;! Render 3D
RenderWorld
;! Render 2D
Text 0, 0, "Escape to Quit"
Text 0,15, "Installed Apps: " + SteamAppList_Count
Local SAL.SteamAppList, Index = 0
For SAL.SteamAppList = Each SteamAppList
Index = Index + 1
Text 0, 30 + Index* 15, RSet(SAL\AppId, 6) + "/" + RSet(SAL\BuildId, 8) + ": " + SAL\Name + " (Installed: '" + SAL\InstallDir + "')"
Next
;! Update Window
Flip 0
WaitTimer(demoTimer)
Until EndGame = True
; Shut down Steam as the last action of your program.
BS_Steam_Shutdown()
End
;~IDEal Editor Parameters:
;~C#Blitz3D
+179
View File
@@ -0,0 +1,179 @@
; BlitzSteam - Steam wrapper for Blitz
; Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU Lesser General Public License as
; published by the Free Software Foundation, either version 3 of the
; License, or (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU Lesser General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
Include "../BlitzSteam.bb"
; Initialize Steam before your next call to Graphics.
If BS_Steam_Init() = False Then
RuntimeError "Steam: Failed to initialize!"
EndIf
Const FPS = 30
Const FPS_MULT# = 1.0 / FPS
; Demo Scene
Graphics3D 1024, 768, 32, 2
SetBuffer BackBuffer()
Local demoTimer = CreateTimer(FPS)
Local demoRoot = CreatePivot()
Local demoCameraRoot = CreatePivot(demoRoot)
Local demoCamera = CreateCamera(demoCameraRoot)
MoveEntity demoCamera, 0, 0, -10
Local demoCube = CreateCube(demoRoot)
; SteamApps Stuff
Type SteamAppsDLC
Field Id%
Field Available%
Field Name$
End Type
Global SteamAppsDLC_Count
Function SteamAppsDLC_Fill()
Local IdBuffer = CreateBank(4)
Local AvailableBuffer = CreateBank(4)
Local NameBuffer = CreateBank(1024)
SteamAppsDLC_Count = BS_Apps_GetDLCCount(BS_Apps())
Delete Each SteamAppsDLC
For Index = 0 To SteamAppsDLC_Count - 1
If BS_Apps_GetDLCDataByIndex(BS_Apps(), Index, IdBuffer, AvailableBuffer, NameBuffer, 1024)
Local SAD.SteamAppsDLC = New SteamAppsDLC
SAD\Id = PeekInt(IdBuffer, 0)
SAD\Available = PeekInt(AvailableBuffer, 0)
SAD\Name = PeekCString(NameBuffer, 0, 1024)
Else
SteamAppsDLC_Count = SteamAppsDLC_Count - 1
EndIf
Next
FreeBank NameBuffer
FreeBank AvailableBuffer
FreeBank IdBuffer
End Function
Type SteamAppsDepots
Field DepotId
End Type
Global SteamAppsDepots_Count
Function SteamAppsDepots_Fill()
Local DepotsBuffer
; Exercise: Do this one yourself with the above Type. It's not that hard.
End Function
Function PeekCString$(Bank, Offset=0, Length=-1)
Local Out$ = "", Pos = Offset
While Abs(Length) > 0
Length = Length - 1
Local by = PeekByte(Bank, Pos)
If by = 0 Then
Length = 0
Else
Out = Out + Chr(by)
EndIf
Pos = Pos + 1
Wend
Return Out
End Function
Local BetaBuffer = CreateBank(1024)
BS_Apps_GetCurrentBetaName(BS_Apps(), BetaBuffer, 1024)
Local Beta$ = PeekCString(BetaBuffer, 0, 1024)
FreeBank BetaBuffer
Local AppInstallDir$, AppInstallDirBuffer = CreateBank(260)
BS_Apps_GetAppInstallDir(BS_Apps(), 480, AppInstallDirBuffer, 260)
AppInstallDir = PeekCString(AppInstallDirBuffer, 0, 260)
FreeBank AppInstallDirBuffer
Local llOwner = BS_Apps_GetAppOwner(BS_Apps())
Local OwnerId$ = "[U:" + BS_CSteamID_GetAccountInstance(llOwner) + ":" + BS_CSteamID_GetAccountID(llOwner) + "] STEAM_" + (BS_CSteamID_GetEAccountType(llOwner) - 1) + ":" + (BS_CSteamID_GetEUniverse(llOwner) - 1) + ":" + (BS_CSteamID_GetAccountID(llOwner) / 2)
BS_CSteamID_Destroy llOwner
; Main Loop
Local EndGame = False
Repeat
Cls
;! Update
; End on Escape
EndGame = KeyHit(1)
TurnEntity demoCube, 1 * FPS_MULT, 3 * FPS_MULT, 2.332 * FPS_MULT
;! Render 3D
RenderWorld
;! Render 2D
Text 0, 0, "Escape to Quit"
Text 0, 30, "Is Subscribed? " + BS_Apps_IsSubscribed(BS_Apps())
Text 0, 45, "Is Low Violence? " + BS_Apps_IsLowViolence(BS_Apps())
Text 0, 60, "Is Cybercafe? " + BS_Apps_IsCybercafe(BS_Apps())
Text 0, 75, "Is VAC Banned? " + BS_Apps_IsVACBanned(BS_Apps())
Text 0, 90, "Current Game Language: " + BS_Apps_GetCurrentGameLanguage(BS_Apps())
Text 0,105, "Available Game Languages: " + BS_Apps_GetAvailableGameLanguages(BS_Apps())
Text 0,120, "Is Subscribed App (480)? " + BS_Apps_IsSubscribedApp(BS_Apps(), 480)
Text 0,135, "Is DLC (323180) Installed? " + BS_Apps_IsDlcInstalled(BS_Apps(), 323180) ; Portal 2 Soundtrack DLC
Text 0,150, "Earliest Purchase Unix Time (480): " + BS_Apps_GetEarliestPurchaseUnixTime(BS_Apps(), 480)
Text 0,165, "Is Subscribed from Free Weekend? " + BS_Apps_IsSubscribedFromFreeWeekend(BS_Apps())
Text 0,180, "DLC Count: " + BS_Apps_GetDLCCount(BS_Apps())
Text 0,195, "Current Beta Name: " + Beta
Text 0,210, "App Install Dir: " + AppInstallDir$
Text 0,225, "Is App Installed (480): " + BS_Apps_IsAppInstalled(BS_Apps(), 480)
Text 0,240, "App Owner Id: " + OwnerId
Text 0,255, "App Built Id: " + BS_Apps_GetAppBuildId(BS_Apps())
; BS_Apps_GetLanchQueryParam$(BS_Apps(), pchKey$)
; // Returns the associated launch param if the game is run via steam://run/<appid>//?param1=value1;param2=value2;param3=value3 etc.
; // Parameter names starting with the character '@' are reserved for internal use and will always return and empty string.
; // Parameter names starting with an underscore '_' are reserved for steam features -- they can be queried by the game,
; // but it is advised that you not param names beginning with an underscore for your own features.
; BS_Apps_MarkContentCorrupt signals steam that game files are corrupt or missing. Forces a validation after quit and before next start.
; How To Use: BS_Apps_RequestProofOfPurchaseKey(BS_Apps(), nAppId)
; // Request cd-key for yourself or owned DLC. If you are interested in this
; // data then make sure you provide us with a list of valid keys to be distributed
; // to users when they purchase the game, before the game ships.
; // You'll receive an AppProofOfPurchaseKeyResponse_t callback when
; // the key is available (which may be immediately).
; Example (Spacewar) does not have CD-Keys.
Text 512, 0, "DLCs: " + SteamAppsDLC_Count
Local Index = 0, SAD.SteamAppsDLC
For SAD = Each SteamAppsDLC
Text 512, 15 + Index * 15, SAD\Id + "(" + SAD\Available + "): " + SAD\Name
; You could install DLCs from the app itself, BS_Apps_InstallDLC, BS_Apps_UninstallDLC
; BS_Apps_GetDlcDownloadProgress allows you to check the progress, BlitzUtility's LongLong stuff is useful here.
Index = Index + 1
Next
;! Update Window
Flip 0
WaitTimer(demoTimer)
Until EndGame = True
; Shut down Steam as the last action of your program.
BS_Steam_Shutdown()
End
;~IDEal Editor Parameters:
;~C#Blitz3D
@@ -0,0 +1,68 @@
; BlitzSteam - Steam wrapper for Blitz
; Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU Lesser General Public License as
; published by the Free Software Foundation, either version 3 of the
; License, or (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU Lesser General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
Include "../BlitzSteam.bb"
;! Example is incomplete, I do not own a Steam Controller.
; Initialize Steam before your next call to Graphics.
If BS_Steam_Init() = False Then
RuntimeError "Steam: Failed to initialize!"
EndIf
Const FPS = 30
Const FPS_MULT# = 1.0 / FPS
; Demo Scene
Graphics3D 1024, 768, 32, 2
SetBuffer BackBuffer()
Local tickTimer = CreateTimer(FPS)
Local demoRoot = CreatePivot()
Local demoCameraRoot = CreatePivot(demoRoot)
Local demoCamera = CreateCamera(demoCameraRoot)
MoveEntity demoCamera, 0, 0, -10
Local demoCube = CreateCube(demoRoot)
Local EndGame = False
Repeat
Cls
;! Update
; End on Escape
EndGame = KeyHit(1)
TurnEntity demoCube, 1 * FPS_MULT, 3 * FPS_MULT, 2.332 * FPS_MULT
;! Render 3D
RenderWorld
;! Render 2D
Text 0, 0, "Escape to Quit"
;! Update Window
Flip 0
WaitTimer(demoTimer)
Until EndGame = True
; Shut down Steam as the last action of your program.
BS_Steam_Shutdown()
End
;~IDEal Editor Parameters:
;~C#Blitz3D
@@ -0,0 +1,269 @@
Include "../BlitzSteam.bb"
Stop
;----------------------------------------------------------------
;! Steam Stuff
;----------------------------------------------------------------
; SteamClient: WarningMessageHook
Global Steam_WarningMessageHook_Callback = 0
Function Steam_WarningMessageHook(bIsWarning%, pchMessageBuffer%)
If Steam_WarningMessageHook_Callback = 0 Then
Steam_WarningMessageHook_Callback = BP_GetFunctionPointer()
Return
EndIf
; Read Message from buffer
Local msg$ = ""
If bIsWarning = 1 Then
msg = "[Warning]"
Else
msg = "[Info]"
EndIf
msg = msg + PeekMemoryStringC(pchMessageBuffer)
DebugLog "[Steam]" + msg$
End Function:Steam_WarningMessageHook(0, 0)
Function PeekMemoryStringC(Memory%, Length%=-1)
Local Ptr = Memory
Local iChar = 0, tiChar = 0
Local sOut$ = ""
Repeat
tiChar = PeekMemoryByte(Ptr)
; Advance memory, decrease Length
Ptr = Ptr + 1
Length = Length - 1
If (tiChar = 0) Then
Length = 0
Else
sOut = sOut + Chr(tiChar)
EndIf
Until Length = 0
Return sOut
End Function
;----------------------------------------------------------------
;! Blitz Browser Wrapper (Image based)
;----------------------------------------------------------------
Type Browser
Field Id%
Field ImageHandle%, ImageSize[2]
; Internal Steam
Field z_llSteamAPICall%
End Type
Global Browser_HTMLSurface_BrowserReady_p = 0, Browser_HTMLSurface_BrowserReady_c = 0
Function Browser_HTMLSurface_BrowserReady(pvParam%, bIOFailure, llSteamAPICall)
If (Browser_HTMLSurface_BrowserReady_p = 0) Then
Browser_HTMLSurface_BrowserReady_p = BP_GetFunctionPointer()
Browser_HTMLSurface_BrowserReady_c = BS_Callback_Create(Browser_HTMLSurface_BrowserReady_p)
Return
EndIf
DebugLog "HTMLSurface_BrowserReady"
Local Browser.Browser = Browser_FindBySteamAPICall(llSteamAPICall)
Browser\Id = PeekMemoryInt(pvParam)
Browser_LoadURL(Browser, "http://google.com/")
Browser_SetSize(Browser, Browser\ImageSize[0], Browser\ImageSize[1])
; Cleanup
BS_Long_Destroy Browser\z_llSteamAPICall : Browser\z_llSteamAPICall = 0
BS_Callback_UnregisterResult Browser_HTMLSurface_BrowserReady_c ; Caller does this too.
End Function:Browser_HTMLSurface_BrowserReady(0, 0, 0)
Global Browser_HTMLSurface_NeedsPaint_p = 0, Browser_HTMLSurface_NeedsPaint_c = 0
Function Browser_HTMLSurface_NeedsPaint(pvParam%, p2, p3)
If (Browser_HTMLSurface_NeedsPaint_p = 0) Then
Browser_HTMLSurface_NeedsPaint_p = BP_GetFunctionPointer()
Browser_HTMLSurface_NeedsPaint_c = BS_Callback_Create(Browser_HTMLSurface_NeedsPaint_p)
Return
EndIf
DebugLog "HTMLSurface_NeedsPaint"
Local Browser.Browser = Browser_FindById(PeekMemoryInt(pvParam))
; Paint logic
;CALLBACK_MEMBER(0, HHTMLBrowser, unBrowserHandle) // the browser that needs the paint
;CALLBACK_MEMBER(1, const char *, pBGRA ) // a pointer to the B8G8R8A8 data for this surface, valid until SteamAPI_RunCallbacks is next called
;CALLBACK_MEMBER(2, uint32, unWide) // the total width of the pBGRA texture
;CALLBACK_MEMBER(3, uint32, unTall) // the total height of the pBGRA texture
;CALLBACK_MEMBER(4, uint32, unUpdateX) // the offset in X for the damage rect for this update
;CALLBACK_MEMBER(5, uint32, unUpdateY) // the offset in Y for the damage rect for this update
;CALLBACK_MEMBER(6, uint32, unUpdateWide) // the width of the damage rect for this update
;CALLBACK_MEMBER(7, uint32, unUpdateTall) // the height of the damage rect for this update
;CALLBACK_MEMBER(8, uint32, unScrollX) // the page scroll the browser was at when this texture was rendered
;CALLBACK_MEMBER(9, uint32, unScrollY) // the page scroll the browser was at when this texture was rendered
;CALLBACK_MEMBER(10, float, flPageScale) // the page scale factor on this page when rendered
;CALLBACK_MEMBER(11, uint32, unPageSerial) // incremented on each new page load, you can use this to reject draws while navigating to new pages
End Function:Browser_HTMLSurface_NeedsPaint(0, 0, 0)
Global Browser_HTMLSurface_StartRequest_p = 0, Browser_HTMLSurface_StartRequest_c = 0
Function Browser_HTMLSurface_StartRequest(pvParam%, p2, p3)
If (Browser_HTMLSurface_StartRequest_p = 0) Then
Browser_HTMLSurface_StartRequest_p = BP_GetFunctionPointer()
Browser_HTMLSurface_StartRequest_c = BS_Callback_Create(Browser_HTMLSurface_StartRequest_p)
Return
EndIf
DebugLog "HTMLSurface_StartRequest"
; Default to allow all requests. (Why not? For an Example, this is good enough.)
BS_HTMLSurface_AllowStartRequest BS_HTMLSurface(), PeekMemoryInt(pvParam), True
End Function:Browser_HTMLSurface_StartRequest(0, 0, 0)
Function Browser_Create.Browser(Width%, Height, UserAgent$="BlitzSteam", UserCSS$="")
DebugLog "[Browser::Create] Creating with UserAgent '"+UserAgent+"' and CSS '"+UserCSS+"'."
; Register Callbacks (Can do this in an Init function too)
;BS_Callback_Register Browser_HTMLSurface_BrowserReady_c, BS_HTMLSurface_BrowserReady
BS_Callback_Register Browser_HTMLSurface_NeedsPaint_c, BS_HTMLSurface_NeedsPaint
BS_Callback_Register Browser_HTMLSurface_StartRequest_c, BS_HTMLSurface_StartRequest
; Create Browser Object
Local Browser.Browser = New Browser
Browser\z_llSteamAPICall = BS_HTMLSurface_CreateBrowser(BS_HTMLSurface(), UserAgent, UserCSS)
Browser\ImageSize[0] = Width
Browser\ImageSize[1] = Height
DebugLog "llSteamAPICall: " + Hex(BS_Long_ToIH(Browser\z_llSteamAPICall)) + Hex(BS_Long_ToIL(Browser\z_llSteamAPICall))
; Register CallResult
BS_Callback_RegisterResult Browser_HTMLSurface_BrowserReady_c, Browser\z_llSteamAPICall, BS_HTMLSurface_BrowserReady
Return Browser
End Function
Function Browser_IsReady(Browser.Browser)
If Browser = Null Then Return False
DebugLog "[Browser::IsReady] Checking if '"+Browser\Id+"'/'"+Hex(BS_Long_ToIH(Browser\z_llSteamAPICall)) + Hex(BS_Long_ToIL(Browser\z_llSteamAPICall))+"' is ready."
Return (Browser\Id <> 0)
End Function
Function Browser_FindById.Browser(Id%)
If Id = 0 Then Return Null ; 0 is not a valid Browser Handle.
DebugLog "[Browser::FindById] Finding by Id '"+Id+"."
Local Browser.Browser
For Browser = Each Browser
If Browser\Id = Id Then Return Browser
Next
Return Null
End Function
Function Browser_FindBySteamAPICall.Browser(llSteamAPICall%)
If llSteamAPICall = 0 Then Return Null ; 0 is not a valid SteamAPICall.
DebugLog "[Browser::FindBySteamAPICall] Finding by SteamAPICall '"+llSteamAPICall+"."
Local Browser.Browser
For Browser = Each Browser
If BS_Long_Compare(Browser\z_llSteamAPICall,llSteamAPICall) = 0 Then Return Browser
Next
Return Null
End Function
Function Browser_Destroy.Browser(Browser.Browser)
If Browser = Null Then Return Null
DebugLog "[Browser::Destroy] Destroying '"+Browser\Id+"'."
BS_HTMLSurface_RemoveBrowser BS_HTMLSurface(), Browser\Id
Delete Browser:Return Null
End Function
Function Browser_SetSize(Browser.Browser, Width%, Height%)
If Browser = Null Then Return
DebugLog "[Browser::SetSize] Resizing '"+Browser\Id+"' to "+Width+"x"+Height+"."
; Free old Image
If (Browser\ImageHandle <> 0) Then
FreeImage(Browser\ImageHandle)
EndIf
; Create new Image
Browser\ImageHandle = CreateImage(Width%, Height%)
Browser\ImageSize[0] = Width
Browser\ImageSize[1] = Height
BS_HTMLSurface_SetSize BS_HTMLSurface(), Browser\Id, Width, Height
End Function
Function Browser_GetHandle(Browser.Browser)
Return Browser\ImageHandle
End Function
Function Browser_LoadURL(Browser.Browser, URL$, PostData$="")
If Browser = Null Then Return
DebugLog "[Browser::SetSize] Browser '"+Browser\Id+"' is loading URL '"+URL+"'."
BS_HTMLSurface_LoadURL BS_HTMLSurface(), Browser\Id, URL, PostData
End Function
;----------------------------------------------------------------
;! Example Code
;----------------------------------------------------------------
If BS_Steam_Init() = 0 Then RuntimeError "Steam failed to initialize."
; Steam: Hooks, Callbacks, CallResults
BS_Client_SetWarningMessageHook BS_Client(), Steam_WarningMessageHook_Callback
; Steam: HTMLSurface API
If BS_HTMLSurface() = 0 Then RuntimeError "Steam: HTMLSurface API is not available."
If BS_HTMLSurface_Init(BS_HTMLSurface()) = 0 Then RuntimeError "Steam: HTMLSurface API did not want to be initialized?!"
BS_HTMLSurface_SetSize BS_HTMLSurface(), 0, GraphicsWidth(), GraphicsHeight()
; Scene Setup
Graphics3D 1024, 768, 32, 2:SetBuffer BackBuffer()
; Create a Browser
Local myBrowser.Browser = Browser_Create(512, 512)
Repeat
BS_Steam_RunCallbacks()
Delay 100
Until Browser_IsReady(myBrowser)
While Not KeyHit(1)
Cls
; Steam: Run any Callbacks
; Q: Why before RenderWorld/Flip?
; A: If we did any changes, having them available before Rendering helps responsiveness.
; A one-frame Delay is noticeable, even to people claiming the eye only sees 30 fps.
; Please read a Biology book if you are one of those, it doesn't work like that.
BS_Steam_RunCallbacks()
RenderWorld
DrawImage Browser_GetHandle(myBrowser), 0, 0, 0
Flip
Wend
; Destroy existing Browser
myBrowser = Browser_Destroy(myBrowser)
; Steam: HTMLSurface API
BS_HTMLSurface_Shutdown(BS_HTMLSurface())
EndGraphics
End
;~IDEal Editor Parameters:
;~C#Blitz3D
+1
View File
@@ -0,0 +1 @@
480