mirror of
https://github.com/zenith391/OCEmu.git
synced 2025-09-08 12:25:45 -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/lua
|
||||||
src/loot
|
src/loot
|
||||||
src/unifont.hex
|
src/font.hex
|
||||||
src/tmpfs
|
src/tmpfs
|
||||||
log.txt
|
log.txt
|
||||||
|
8
Makefile
8
Makefile
@ -1,6 +1,6 @@
|
|||||||
ASSETS=https://github.com/MightyPirates/OpenComputers/trunk/src/main/resources/assets/opencomputers
|
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:
|
src/lua:
|
||||||
svn export $(ASSETS)/lua src/lua
|
svn export $(ASSETS)/lua src/lua
|
||||||
@ -8,10 +8,10 @@ src/lua:
|
|||||||
src/loot:
|
src/loot:
|
||||||
svn export $(ASSETS)/loot src/loot
|
svn export $(ASSETS)/loot src/loot
|
||||||
|
|
||||||
src/unifont.hex:
|
src/font.hex:
|
||||||
svn export $(ASSETS)/unifont.hex src/unifont.hex
|
svn export $(ASSETS)/font.hex src/font.hex
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf src/lua
|
rm -rf src/lua
|
||||||
rm -rf src/loot
|
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
|
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
|
# 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**
|
**Windows**
|
||||||
|
@ -172,7 +172,7 @@ end
|
|||||||
local char8 = ffi.new("uint32_t[?]", 8*16)
|
local char8 = ffi.new("uint32_t[?]", 8*16)
|
||||||
local char16 = ffi.new("uint32_t[?]", 16*16)
|
local char16 = ffi.new("uint32_t[?]", 16*16)
|
||||||
local function _renderChar(ochar)
|
local function _renderChar(ochar)
|
||||||
char = unifont[ochar]
|
char = font[ochar]
|
||||||
local size,pchar = #char/16
|
local size,pchar = #char/16
|
||||||
if size == 2 then
|
if size == 2 then
|
||||||
pchar = char8
|
pchar = char8
|
||||||
@ -197,7 +197,7 @@ local function _renderChar(ochar)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function renderChar(char,x,y,fg,bg)
|
local function renderChar(char,x,y,fg,bg)
|
||||||
if unifont[char] == nil then
|
if font[char] == nil then
|
||||||
char = 63
|
char = 63
|
||||||
end
|
end
|
||||||
if not charCache[char] then
|
if not charCache[char] then
|
||||||
@ -205,7 +205,7 @@ local function renderChar(char,x,y,fg,bg)
|
|||||||
end
|
end
|
||||||
local br, bg, bb = extract(bg)
|
local br, bg, bb = extract(bg)
|
||||||
SDL.setRenderDrawColor(renderer, br, bg, bb, 255)
|
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)
|
SDL.renderFillRect(renderer, dest)
|
||||||
if char~=32 then
|
if char~=32 then
|
||||||
SDL.setTextureColorMod(charCache[char], extract(fg))
|
SDL.setTextureColorMod(charCache[char], extract(fg))
|
||||||
|
12
src/main.lua
12
src/main.lua
@ -274,15 +274,15 @@ setmetatable(env,{
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- load unifont
|
-- load font
|
||||||
unifont = {}
|
font = {}
|
||||||
for line in elsa.filesystem.lines("unifont.hex") do
|
for line in elsa.filesystem.lines("font.hex") do
|
||||||
local a,b = line:match("(.+):(.*)")
|
local a,b = line:match("(.+):(.*)")
|
||||||
unifont[tonumber(a,16)] = b
|
font[tonumber(a,16)] = b
|
||||||
end
|
end
|
||||||
function getCharWidth(char)
|
function getCharWidth(char)
|
||||||
if unifont[char] ~= nil then
|
if font[char] ~= nil then
|
||||||
return #unifont[char] / 32
|
return #font[char] / 32
|
||||||
end
|
end
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user