Improve load screen

This commit is contained in:
Lubos Lenco 2018-01-22 18:46:38 +01:00
parent 88d8e070e3
commit ad54883bf3
6 changed files with 23 additions and 20 deletions

View file

@ -135,8 +135,7 @@ void main() {
#else
// TODO: merge..
// float cosAngle = max(1.0 - dotNL, 0.0);
// vec3 noff = n * shadowsBias * cosAngle;
// vec3 noff = n * 0.003;
if (lightShadow == 1) {
// vec4 lPos = LWVP * vec4(p + noff, 1.0);
vec4 lPos = LWVP * vec4(p, 1.0);

View file

@ -1,14 +0,0 @@
package armory.trait.internal;
class LoadBar {
public static function render(g:kha.graphics2.Graphics) {
if (iron.Scene.active != null && iron.Scene.active.ready) {
iron.App.removeRender2D(LoadBar.render);
return;
}
g.color = 0xffcf2b43;
g.fillRect(0, iron.App.h() - 4, iron.App.w() / Main.projectAssets * iron.data.Data.assetsLoaded, 4);
}
}

View file

@ -0,0 +1,11 @@
package armory.trait.internal;
// To create a custom loading screen copy this file to blend_root/Sources/arm/LoadingScreen.hx
class LoadingScreen {
public static function render(g:kha.graphics2.Graphics, assetsLoaded:Int, assetsTotal:Int) {
g.color = 0xffcf2b43;
g.fillRect(0, iron.App.h() - 6, iron.App.w() / assetsTotal * assetsLoaded, 6);
}
}

View file

@ -137,7 +137,7 @@ def init_properties():
('Native', 'C++', 'Native'),
('Krom', 'Krom', 'Krom')],
name="Runtime", description="Player runtime used when launching in new window", default='Krom', update=assets.invalidate_shader_cache)
bpy.types.World.arm_loadbar = BoolProperty(name="Load Bar", description="Show asset loading progress on published builds", default=True)
bpy.types.World.arm_loadscreen = BoolProperty(name="Loading Screen", description="Show asset loading progress on published builds", default=True)
bpy.types.World.arm_vsync = BoolProperty(name="VSync", description="Vertical Synchronization", default=True, update=invalidate_compiler_cache)
bpy.types.World.arm_dce = BoolProperty(name="DCE", description="Enable dead code elimination for publish builds", default=True, update=invalidate_compiler_cache)
bpy.types.World.arm_asset_compression = BoolProperty(name="Asset Compression", description="Enable scene data compression", default=False, update=invalidate_compiler_cache)

View file

@ -447,7 +447,7 @@ class ArmoryProjectPanel(bpy.types.Panel):
row = layout.row()
col = row.column()
col.prop(wrd, 'arm_vsync')
col.prop(wrd, 'arm_loadbar')
col.prop(wrd, 'arm_loadscreen')
col.prop(wrd, 'arm_winmode')
col = row.column()

View file

@ -302,9 +302,16 @@ class Main {
kha.System.init({title: projectName, width: projectWidth, height: projectHeight, samplesPerPixel: projectSamplesPerPixel, vSync: projectVSync, windowMode: projectWindowMode, resizable: projectWindowResize, maximizable: projectWindowMaximize, minimizable: projectWindowMinimize}, function() {
iron.App.init(function() {
""")
if is_publish and wrd.arm_loadbar:
if is_publish and wrd.arm_loadscreen:
loadscreen_class = 'armory.trait.internal.LoadingScreen'
if os.path.isfile(arm.utils.get_fp() + '/Sources/' + wrd.arm_project_package + '/LoadingScreen.hx'):
loadscreen_class = wrd.arm_project_package + '.LoadingScreen'
f.write("""
iron.App.notifyOnRender2D(armory.trait.internal.LoadBar.render);
function drawLoading(g:kha.graphics2.Graphics) {
if (iron.Scene.active != null && iron.Scene.active.ready) iron.App.removeRender2D(drawLoading);
else """ + loadscreen_class + """.render(g, iron.data.Data.assetsLoaded, Main.projectAssets);
}
iron.App.notifyOnRender2D(drawLoading);
""")
f.write("""