Use new Kha

This commit is contained in:
luboslenco 2018-09-05 08:49:44 +02:00
parent 8bb14e766a
commit ddea3b7cea
6 changed files with 17 additions and 45 deletions

View file

@ -9,12 +9,7 @@ class DisplayInfoNode extends LogicNode {
}
override function get(from:Int):Dynamic {
#if (kha_version < 1807) // TODO: deprecated
if (from == 0) return kha.Display.width(displayIndex);
else return kha.Display.height(displayIndex);
#else
if (from == 0) return kha.Display.all[displayIndex].width;
else return kha.Display.all[displayIndex].height;
#end
}
}

View file

@ -7,10 +7,6 @@ class ShutdownNode extends LogicNode {
}
override function run() {
#if (kha_version < 1807) // TODO: deprecated
kha.System.requestShutdown();
#else
kha.System.stop();
#end
}
}

View file

@ -27,17 +27,12 @@ class Starter {
armory.object.Uniforms.register();
var windowMode = c.window_mode == 0 ? kha.WindowMode.Window : kha.WindowMode.Fullscreen;
#if (kha_version < 1807) // TODO: deprecated
if (windowMode == kha.WindowMode.Fullscreen) { windowMode = kha.WindowMode.BorderlessWindow; c.window_w = kha.Display.width(0); c.window_h = kha.Display.height(0); }
kha.System.init({title: Main.projectName, width: c.window_w, height: c.window_h, samplesPerPixel: c.window_msaa, vSync: c.window_vsync, windowMode: windowMode, resizable: c.window_resizable, maximizable: c.window_maximizable, minimizable: c.window_minimizable}, function() {
#else
var windowMode = c.window_mode == 0 ? kha.WindowMode.Windowed : kha.WindowMode.Fullscreen;
var windowFeatures = 0;
if (c.window_resizable) windowFeatures |= kha.WindowOptions.FeatureResizable;
if (c.window_maximizable) windowFeatures |= kha.WindowOptions.FeatureMaximizable;
if (c.window_minimizable) windowFeatures |= kha.WindowOptions.FeatureMinimizable;
kha.System.start({title: Main.projectName, width: c.window_w, height: c.window_h, window: {mode: windowMode, windowFeatures: windowFeatures}, framebuffer: {samplesPerPixel: c.window_msaa, verticalSync: c.window_vsync}}, function(window:kha.Window) {
#end
iron.App.init(function() {
#if arm_loadscreen
function load(g:kha.graphics2.Graphics) {

View file

@ -465,10 +465,8 @@ def build_success():
if arm.utils.get_os() == 'win':
cmd.append('--consolepid')
cmd.append(str(os.getpid()))
elif arm.utils.get_os() == 'mac': # TODO: Krom sound freezes on MacOS
elif arm.utils.get_os() == 'mac' or arm.utils.get_os() == 'linux': # TODO: Wait for new Krom audio
cmd.append('--nosound')
# cmd.append('--stdout')
# cmd.append(arm.utils.get_fp_build() + '/krom.txt')
state.proc_play = run_proc(cmd, play_done)
elif wrd.arm_play_runtime == 'Native':
if arm.utils.get_os() == 'win':
@ -476,7 +474,7 @@ def build_success():
elif arm.utils.get_os() == 'linux':
bin_location = arm.utils.get_fp_build() + '/linux'
else:
bin_location = arm.utils.get_fp_build() + '/osx'
bin_location = arm.utils.get_fp_build() + '/osx-build/build/Release'
os.chdir(bin_location)
if arm.utils.get_os() == 'win':
p = bin_location + '/' + arm.utils.safestr(wrd.arm_project_name) + '.exe'
@ -509,36 +507,23 @@ def build_success():
os.remove(mapfile)
# Copy Krom binaries
if state.target == 'krom-windows':
krom_location = sdk_path + '/Krom/win32/'
gapi = state.export_gapi
ext = '' if gapi == 'opengl' else '_' + gapi
krom_location = sdk_path + '/Krom/Krom' + ext + '.exe'
shutil.copy(krom_location, files_path + '/Krom.exe')
os.rename(files_path + '/Krom.exe', files_path + '/' + arm.utils.safestr(wrd.arm_project_name) + '.exe')
elif state.target == 'krom-linux':
krom_location = sdk_path + '/Krom/linux/'
krom_location = sdk_path + '/Krom/Krom'
shutil.copy(krom_location, files_path)
os.rename(files_path + '/Krom', files_path + '/' + arm.utils.safestr(wrd.arm_project_name))
else:
krom_location = sdk_path + '/Krom/macos/Krom.app'
if state.target == 'krom-macos':
krom_location = sdk_path + '/Krom/Krom.app'
shutil.copytree(krom_location, files_path + '/Krom.app')
game_files = os.listdir(files_path)
for f in game_files:
f = files_path + '/' + f
if os.path.isfile(f):
shutil.move(f, files_path + '/Krom.app/Contents/MacOS')
else:
krom_files = os.listdir(krom_location)
for f in krom_files:
f = krom_location + '/' + f
if os.path.isfile(f):
shutil.copy(f, files_path)
if state.target == 'krom-windows':
gapi = state.export_gapi
ext = '' if gapi == 'opengl' else '_' + gapi
bin_path = files_path + '/Krom' + ext + '.exe'
os.rename(bin_path, files_path + '/' + arm.utils.safestr(wrd.arm_project_name) + '.exe')
if gapi != 'opengl' and os.path.exists(files_path + '/Krom.exe'):
os.remove(files_path + '/Krom.exe')
if gapi != 'direct3d11' and os.path.exists(files_path + '/Krom_direct3d11.exe'):
os.remove(files_path + '/Krom_direct3d11.exe')
elif state.target == 'krom-linux':
os.rename(files_path + '/Krom', files_path + '/' + arm.utils.safestr(wrd.arm_project_name))
else:
os.rename(files_path + '/Krom.app', files_path + '/' + arm.utils.safestr(wrd.arm_project_name) + '.app')
# Rename
ext = state.target.split('-')[-1] # krom-windows

View file

@ -239,6 +239,7 @@ class ArmEditScriptButton(bpy.types.Operator):
if bpy.data.worlds['Arm'].arm_play_runtime != 'Browser' or not os.path.exists(arm.utils.get_fp() + "/khafile.js"):
print('Generating HTML5 project for Kode Studio')
arm.utils.check_default_props()
make.build('html5')
if self.is_object:
@ -309,7 +310,7 @@ class ArmEditCanvasButton(bpy.types.Operator):
canvas_path = project_path + '/Bundled/canvas/' + item.canvas_name_prop + '.json'
sdk_path = arm.utils.get_sdk_path()
armory2d_path = sdk_path + '/lib/armory_tools/armory2d/krom'
armory2d_path = sdk_path + '/lib/armory_tools/armory2d'
krom_location, krom_path = arm.utils.krom_paths()
os.chdir(krom_location)
cpath = canvas_path.replace('\\', '/')

View file

@ -198,13 +198,13 @@ def get_khamake_path():
def krom_paths(bin_ext=''):
sdk_path = get_sdk_path()
if arm.utils.get_os() == 'win':
krom_location = sdk_path + '/Krom/win32'
krom_location = sdk_path + '/Krom'
krom_path = krom_location + '/Krom' + bin_ext + '.exe'
elif arm.utils.get_os() == 'mac':
krom_location = sdk_path + '/Krom/macos/Krom.app/Contents/MacOS'
krom_location = sdk_path + '/Krom/Krom.app/Contents/MacOS'
krom_path = krom_location + '/Krom' + bin_ext
else:
krom_location = sdk_path + '/Krom/linux'
krom_location = sdk_path + '/Krom'
krom_path = krom_location + '/Krom' + bin_ext
return krom_location, krom_path