#import_plugin Nuklear as nk

// show all errors
SetErrorMode(2)

// set window properties
SetWindowTitle( "First Nuklear Window" )
SetWindowSize( 1280, 720, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window

// set display properties
SetVirtualResolution( 1280, 720 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 0, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts

#insert "../Nuklear.agc"

// basic nuklear initialization
nkInit()

nk.FontStashBegin()
  nk.FontSetGlyphRange(NK_GLYPHRANGE_CYRILLIC)
  nk.FontAtlasAddFromSystem("cyrillic14", "segoeui.ttf", 24)

  nk.FontSetGlyphRange(NK_GLYPHRANGE_CHINESE)
  if nk.FontAtlasAddFromFile("chinese14", "media/NotoSansSC-Regular.otf", 24) <= 0 then message("error")

  nk.FontSetGlyphRange(NK_GLYPHRANGE_KOREAN)
  nk.FontAtlasAddFromFile("korean14", "media/BMYEONSUNG_ttf.ttf", 24)

  nk.FontSetGlyphRange(NK_GLYPHRANGE_JAPANESE)
  nk.FontAtlasAddFromFile("japanese14", "media/ume-hgo4.ttf", 24)

  nk.FontSetGlyphRange(NK_GLYPHRANGE_GREEK)
  nk.FontAtlasAddFromSystem("greek14", "segoeui.ttf", 24)
  
  // vietnamese unicode range
  nk.FontSetGlyphRange(NK_GLYPHRANGE_DEFAULT)
  nk.FontAddGlyphRange(0x0102, 0x0103)
  nk.FontAddGlyphRange(0x0110, 0x0111)
  nk.FontAddGlyphRange(0x0128, 0x0129)
  nk.FontAddGlyphRange(0x0168, 0x0169)
  nk.FontAddGlyphRange(0x01a0, 0x01b0)
  nk.FontAddGlyphRange(0x1ea0, 0x1ef9)
  nk.FontAtlasAddFromSystem("vietnamese14", "segoeui.ttf", 24)
nk.FontStashEnd()

do
	// pass agk inputs to nuklear
    nk.HandleInput()

	nk.StyleSetFont("cyrillic14")
	if nk.WindowBegin("Мое первое окно (Cyrillic)", 40, 25, 400, 200, NK_WINDOW_BORDER||NK_WINDOW_MOVABLE||NK_WINDOW_TITLE)
	endif
	nk.WindowEnd()
	
	nk.StyleSetFont("chinese14")	
	if nk.WindowBegin("迈恩斯特斯·芬斯特 (Chinese)", 450, 25, 400, 200, NK_WINDOW_BORDER||NK_WINDOW_MOVABLE||NK_WINDOW_TITLE)
	endif
	nk.WindowEnd()
	
	nk.StyleSetFont("korean14")
	if nk.WindowBegin("내 첫 창 (Korean)", 860, 25, 400, 200, NK_WINDOW_BORDER||NK_WINDOW_MOVABLE||NK_WINDOW_TITLE)
	endif
	nk.WindowEnd()
	
	nk.StyleSetFont("japanese14")
	if nk.WindowBegin("私の最初のウィンドウ (Japanese)", 40, 250, 400, 200, NK_WINDOW_BORDER||NK_WINDOW_MOVABLE||NK_WINDOW_TITLE)
	endif
	nk.WindowEnd()
	
	nk.StyleSetFont("greek14")
	if nk.WindowBegin("Το πρώτο μου παράθυρο (Greek)", 450, 250, 400, 200, NK_WINDOW_BORDER||NK_WINDOW_MOVABLE||NK_WINDOW_TITLE)
	endif
	nk.WindowEnd()
	
	nk.StyleSetFont("vietnamese14")
	if nk.WindowBegin("Cửa sổ đầu tiên của tôi (Vietnamese)", 860, 250, 400, 200, NK_WINDOW_BORDER||NK_WINDOW_MOVABLE||NK_WINDOW_TITLE)
	endif
	nk.WindowEnd()
	
    nkSync()
loop
