mirror of
https://github.com/zenith391/OCEmu.git
synced 2025-08-03 18:16:55 -04:00
Update to use the new font
This commit is contained in:
parent
14c6d00b4d
commit
bcb7a1ad6a
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,5 +1,5 @@
|
||||
src/lua
|
||||
src/loot
|
||||
src/unifont.hex
|
||||
src/font.hex
|
||||
src/tmpfs
|
||||
log.txt
|
||||
|
8
Makefile
8
Makefile
@ -1,6 +1,6 @@
|
||||
ASSETS=https://github.com/MightyPirates/OpenComputers/trunk/src/main/resources/assets/opencomputers
|
||||
|
||||
all: src/lua src/loot src/unifont.hex
|
||||
all: src/lua src/loot src/font.hex
|
||||
|
||||
src/lua:
|
||||
svn export $(ASSETS)/lua src/lua
|
||||
@ -8,10 +8,10 @@ src/lua:
|
||||
src/loot:
|
||||
svn export $(ASSETS)/loot src/loot
|
||||
|
||||
src/unifont.hex:
|
||||
svn export $(ASSETS)/unifont.hex src/unifont.hex
|
||||
src/font.hex:
|
||||
svn export $(ASSETS)/font.hex src/font.hex
|
||||
|
||||
clean:
|
||||
rm -rf src/lua
|
||||
rm -rf src/loot
|
||||
rm -f src/unifont.hex
|
||||
rm -f src/font.hex
|
||||
|
@ -44,7 +44,7 @@ luarocks-5.2 install luasec
|
||||
luarocks-5.2 install --server=http://luarocks.org/dev luaffi
|
||||
|
||||
# OpenComputer's lua source code is not provided, if you have svn then use the provided Makefile
|
||||
# If you hate svn, manually download assets/loot, assets/lua, and assets/unifont.hex into src/
|
||||
# If you hate svn, manually download assets/loot, assets/lua, and assets/font.hex into src/
|
||||
```
|
||||
|
||||
**Windows**
|
||||
|
@ -172,7 +172,7 @@ end
|
||||
local char8 = ffi.new("uint32_t[?]", 8*16)
|
||||
local char16 = ffi.new("uint32_t[?]", 16*16)
|
||||
local function _renderChar(ochar)
|
||||
char = unifont[ochar]
|
||||
char = font[ochar]
|
||||
local size,pchar = #char/16
|
||||
if size == 2 then
|
||||
pchar = char8
|
||||
@ -197,7 +197,7 @@ local function _renderChar(ochar)
|
||||
end
|
||||
|
||||
local function renderChar(char,x,y,fg,bg)
|
||||
if unifont[char] == nil then
|
||||
if font[char] == nil then
|
||||
char = 63
|
||||
end
|
||||
if not charCache[char] then
|
||||
@ -205,7 +205,7 @@ local function renderChar(char,x,y,fg,bg)
|
||||
end
|
||||
local br, bg, bb = extract(bg)
|
||||
SDL.setRenderDrawColor(renderer, br, bg, bb, 255)
|
||||
local dest = ffi.new("SDL_Rect",{x=x,y=y,w=#unifont[char]/4,h=16})
|
||||
local dest = ffi.new("SDL_Rect",{x=x,y=y,w=#font[char]/4,h=16})
|
||||
SDL.renderFillRect(renderer, dest)
|
||||
if char~=32 then
|
||||
SDL.setTextureColorMod(charCache[char], extract(fg))
|
||||
|
12
src/main.lua
12
src/main.lua
@ -274,15 +274,15 @@ setmetatable(env,{
|
||||
end,
|
||||
})
|
||||
|
||||
-- load unifont
|
||||
unifont = {}
|
||||
for line in elsa.filesystem.lines("unifont.hex") do
|
||||
-- load font
|
||||
font = {}
|
||||
for line in elsa.filesystem.lines("font.hex") do
|
||||
local a,b = line:match("(.+):(.*)")
|
||||
unifont[tonumber(a,16)] = b
|
||||
font[tonumber(a,16)] = b
|
||||
end
|
||||
function getCharWidth(char)
|
||||
if unifont[char] ~= nil then
|
||||
return #unifont[char] / 32
|
||||
if font[char] ~= nil then
|
||||
return #font[char] / 32
|
||||
end
|
||||
return 1
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user