📄 gui_minimap.lua
字号:
-------------------------------------------------------------------------------------------------------------------------------------------------------------------- file: gui_minimap.lua-- brief: a demo widget to show how the minimap can be controlled-- author: Dave Rodgers---- Copyright (C) 2007.-- Licensed under the terms of the GNU GPL, v2 or later.------------------------------------------------------------------------------------------------------------------------------------------------------------------function widget:GetInfo() return { name = "Minimap", desc = "Minimap redirection -- does nothing (for devs)", author = "trepan", date = "Jan 8, 2007", license = "GNU GPL, v2 or later", layer = 0, enabled = false -- loaded by default? }end----------------------------------------------------------------------------------------------------------------------------------------------------------------include("colors.h.lua")local xsize = 300local ysize = 300local minx = 10local miny = 10local maxx = xsize + minx - 1local maxy = ysize + miny - 1local oldGeo = Spring.GetConfigString("MiniMapGeometry", "2 2 200 200")function widget:Initialize() gl.SlaveMiniMap(true) Spring.SendCommands({-- "minimap slavemode 1", string.format("minimap geometry %i %i %i %i", minx, miny, xsize, ysize) })endfunction widget:Shutdown() gl.SlaveMiniMap(false) Spring.SendCommands({-- "minimap slavemode 0", "minimap geometry " .. oldGeo })endlocal vsx, vsy = widgetHandler:GetViewSizes()function widget:ViewResize(viewSizeX, viewSizeY) vsx = viewSizeX vsy = viewSizeYendfunction widget:DrawScreen() if (widgetHandler:InTweakMode()) then Spring.SendCommands({ "minimap min 1" }) else Spring.SendCommands({ "minimap min 0" }) end gl.DrawMiniMap() gl.ResetState() gl.ResetMatrices() local xn = minx - 0.5 local xp = maxx + 0.5 local yn = vsy - (miny - 0.5) local yp = vsy - (maxy + 0.5) gl.Color(1, 1, 1) gl.Shape(GL.LINE_LOOP, { { v = { xn, yn } }, { v = { xp, yn } }, { v = { xp, yp } }, { v = { xn, yp } } }) gl.Color(1, 1, 1) xn = xn - 1 xp = xp + 1 yn = yn + 1 yp = yp - 1 gl.Color(0, 0, 0) gl.Shape(GL.LINE_LOOP, { { v = { xn, yn } }, { v = { xp, yn } }, { v = { xp, yp } }, { v = { xn, yp } } }) end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -