This repository was archived by the owner on Dec 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
268 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
root=true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 4 | ||
indent_style = space | ||
insert_final_newline = true | ||
tab_width = 4 | ||
trim_trailing_whitespace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
require ('common/util') | ||
require ('screens/screens') | ||
|
||
Language = require('common/language'):new() | ||
MusicDefs = require('common/music-defs') | ||
ResourceDefs = require("common/resource-defs") | ||
BasePath = abyss.getConfig("#Abyss", "BasePath") | ||
MPQRoot = abyss.getConfig("System", "MPQRoot") | ||
ShowTrademarkScreen = true | ||
|
||
function LoadGlobals() | ||
-- Load the fonts | ||
SystemFonts = { | ||
FntFormal12 = abyss.loadSpriteFont(Language:i18nPath(ResourceDefs.FontFormal12), ResourceDefs.Palette.Static), | ||
FntFormal10 = abyss.loadSpriteFont(Language:i18nPath(ResourceDefs.FontFormal10), ResourceDefs.Palette.Static), | ||
FntExocet10 = abyss.loadSpriteFont(Language:i18nPath(ResourceDefs.FontExocet10), ResourceDefs.Palette.Static), | ||
FntRidiculous = abyss.loadSpriteFont(Language:i18nPath(ResourceDefs.FontRidiculous), ResourceDefs.Palette.Static) | ||
} | ||
|
||
CursorSprite = abyss.loadSprite(ResourceDefs.CursorDefault, ResourceDefs.Palette.Sky) | ||
CursorSprite.blendMode = "blend" | ||
|
||
ButtonDefs = require("common/button-defs"):new() | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
-- Copyright (C) 2021 Tim Sarbin | ||
-- This file is part of OpenDiablo2 <https://github.com/AbyssEngine/OpenDiablo2>. | ||
-- | ||
-- OpenDiablo2 is free software: you can redistribute it and/or modify | ||
-- it under the terms of the GNU General Public License as published by | ||
-- the Free Software Foundation, either version 3 of the License, or | ||
-- (at your option) any later version. | ||
-- | ||
-- OpenDiablo2 is distributed in the hope that it will be useful, | ||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
-- GNU General Public License for more details. | ||
-- | ||
-- You should have received a copy of the GNU General Public License | ||
-- along with OpenDiablo2. If not, see <http://www.gnu.org/licenses/>. | ||
-- | ||
require("string") | ||
|
||
function Split(s, delimiter) | ||
local result = {}; | ||
for match in (s .. delimiter):gmatch("(.-)" .. delimiter) do | ||
table.insert(result, match); | ||
end | ||
return result; | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
local Credits = { | ||
} | ||
Credits.__index = Credits | ||
|
||
function Credits:new() | ||
local this = {} | ||
setmetatable(this, self) | ||
self:initialize() | ||
return this | ||
end | ||
|
||
function Credits:initialize() | ||
self.creditsLines = abyss.loadString(Language:i18nPath(ResourceDefs.CreditsText)) | ||
|
||
self.rootNode = abyss.getRootNode() | ||
self.rootNode:removeAllChildren() | ||
abyss.resetMouseState() | ||
|
||
self.btnExit = self:createCreditsButton("Exit", 33, 543) | ||
self.btnExit:onActivate(function() SetScreen(Screen.MAIN_MENU) end) | ||
|
||
-- Main Background | ||
self.mainBg = abyss.loadSprite(ResourceDefs.CreditsBackground, ResourceDefs.Palette.Sky) | ||
self.mainBg:setCellSize(4, 3) | ||
|
||
self.rootNode:appendChild(self.mainBg) | ||
self.mainBg:appendChild(self.btnExit) | ||
|
||
end | ||
|
||
function Credits:createCreditsButton(text, x, y) | ||
local result = abyss.createButton(SystemFonts.FntExocet10, ButtonDefs.SprButtonMediumBlank) | ||
result:setSegments(1, 1) | ||
result:setFixedSize(128, 35) | ||
result.caption = text:upper() | ||
result:setPosition(x, y) | ||
result:setTextOffset(0, -2) | ||
result:setFrameIndex("normal", 0) | ||
result:setFrameIndex("pressed", 1) | ||
return result | ||
end | ||
|
||
return Credits |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
local MainMenu = { | ||
} | ||
MainMenu.__index = MainMenu | ||
|
||
function MainMenu:new(showSplash) | ||
local this = {} | ||
setmetatable(this, self) | ||
self:initialize(showSplash) | ||
return this | ||
end | ||
|
||
function MainMenu:initialize() | ||
self.rootNode = abyss.getRootNode() | ||
self.rootNode:removeAllChildren() | ||
abyss.resetMouseState() | ||
|
||
-- OpenDiablo Version Label | ||
self.lblVersion = abyss.loadLabel(SystemFonts.FntFormal12) | ||
self.lblVersion:setPosition(790, 0) | ||
self.lblVersion:setCaption("OpenDiablo II v0.01") | ||
self.lblVersion:setAlignment("end", "middle") | ||
|
||
-- Disclaimer Label | ||
self.lblDisclaimer = abyss.loadLabel(SystemFonts.FntFormal10) | ||
self.lblDisclaimer:setCaption("OpenDiablo II is neither developed by, nor endorsed by Blizzard or its parent company Activision") | ||
self.lblDisclaimer:setPosition(400, 580) | ||
self.lblDisclaimer:setAlignment("middle", "start") | ||
self.lblDisclaimer:setColorMod(0xFF, 0xFF, 0x8C) | ||
|
||
-- Trademark Screen | ||
self.trademarkBg = abyss.loadSprite(ResourceDefs.TrademarkScreen, ResourceDefs.Palette.Sky) | ||
self.trademarkBg:setCellSize(4, 3) | ||
self.trademarkBg:onMouseButtonDown(function(buttons) | ||
abyss.resetMouseState(); | ||
self.trademarkBg.active = false | ||
self.mainBg.active = true | ||
self = nil | ||
end) | ||
|
||
-- Main Background | ||
self.mainBg = abyss.loadSprite(ResourceDefs.GameSelectScreen, ResourceDefs.Palette.Sky) | ||
self.mainBg:setCellSize(4, 3) | ||
self.mainBg.active = false | ||
|
||
-- D2 Logo Left Black BG | ||
self.d2LogoLeftBlackBg = abyss.loadSprite(ResourceDefs.Diablo2LogoBlackLeft, ResourceDefs.Palette.Sky) | ||
self.d2LogoLeftBlackBg:setPosition(400, 120) | ||
self.d2LogoLeftBlackBg.bottomOrigin = true | ||
self.d2LogoLeftBlackBg.playMode = "forwards" | ||
|
||
-- D2 Logo Right Black BG | ||
self.d2LogoRightBlackBg = abyss.loadSprite(ResourceDefs.Diablo2LogoBlackRight, ResourceDefs.Palette.Sky) | ||
self.d2LogoRightBlackBg:setPosition(400, 120) | ||
self.d2LogoRightBlackBg.bottomOrigin = true | ||
self.d2LogoRightBlackBg.playMode = "forwards" | ||
|
||
-- D2 Logo Left | ||
self.d2LogoLeft = abyss.loadSprite(ResourceDefs.Diablo2LogoFireLeft, ResourceDefs.Palette.Sky) | ||
self.d2LogoLeft:setPosition(400, 120) | ||
self.d2LogoLeft.blendMode = "additive" | ||
self.d2LogoLeft.bottomOrigin = true | ||
self.d2LogoLeft.playMode = "forwards" | ||
|
||
-- D2 Logo Right | ||
self.d2LogoRight = abyss.loadSprite(ResourceDefs.Diablo2LogoFireRight, ResourceDefs.Palette.Sky) | ||
self.d2LogoRight:setPosition(400, 120) | ||
self.d2LogoRight.blendMode = "additive" | ||
self.d2LogoRight.bottomOrigin = true | ||
self.d2LogoRight.playMode = "forwards" | ||
|
||
-- Menu Buttons | ||
self.btnSinglePlayer = self:createMainMenuButton("Single Player", 264, 290) | ||
self.btnSinglePlayer:onActivate(function() | ||
-- TODO | ||
end) | ||
|
||
self.btnLocalNetplay = self:createMainMenuButton("Local NetPlay", 264, 330) | ||
self.btnLocalNetplay:onActivate(function() | ||
-- TODO | ||
end) | ||
|
||
self.btnMapEngineDebug = self:createMainMenuButton("Map Engine Debug", 264, 400) | ||
self.btnMapEngineDebug:onActivate(function() | ||
-- TODO | ||
end) | ||
|
||
self.btnCredits = self:createMainMenuMinibutton("Credits", 264, 472) | ||
self.btnCredits:onActivate(function() SetScreen(Screen.CREDITS) end) | ||
|
||
self.btnCinematics = self:createMainMenuMinibutton("Cinematics", 401, 472) | ||
self.btnCinematics:onActivate(function() | ||
-- TODO | ||
end) | ||
|
||
self.btnExitGame = self:createMainMenuButton("Exit to Desktop", 264, 500) | ||
self.btnExitGame:onActivate(function() | ||
abyss.shutdown() | ||
end) | ||
|
||
-- Append all nodes to the scene graph | ||
self.mainBg:appendChild(self.lblVersion) | ||
self.mainBg:appendChild(self.lblDisclaimer) | ||
self.mainBg:appendChild(self.btnSinglePlayer) | ||
self.mainBg:appendChild(self.btnLocalNetplay) | ||
self.mainBg:appendChild(self.btnExitGame) | ||
self.mainBg:appendChild(self.btnCredits) | ||
self.mainBg:appendChild(self.btnCinematics) | ||
self.mainBg:appendChild(self.btnMapEngineDebug) | ||
self.rootNode:appendChild(self.trademarkBg) | ||
self.rootNode:appendChild(self.mainBg) | ||
self.rootNode:appendChild(self.d2LogoLeftBlackBg) | ||
self.rootNode:appendChild(self.d2LogoRightBlackBg) | ||
self.rootNode:appendChild(self.d2LogoLeft) | ||
self.rootNode:appendChild(self.d2LogoRight) | ||
|
||
if ShowTrademarkScreen == false then | ||
self.trademarkBg.active = false | ||
self.mainBg.active = true | ||
else | ||
ShowTrademarkScreen = false | ||
end | ||
end | ||
|
||
function MainMenu:createMainMenuButton(text, x, y) | ||
abyss.log("debug", "Loading button: " .. text) | ||
local result = abyss.createButton(SystemFonts.FntExocet10, ButtonDefs.SprButtonWideBlank) | ||
result:setSegments(2, 1) | ||
result:setFixedSize(272, 35) | ||
result.caption = text:upper() | ||
result:setPosition(x, y) | ||
result:setTextOffset(0, -3) | ||
result:setFrameIndex("normal", 0) | ||
result:setFrameIndex("pressed", 2) | ||
return result | ||
end | ||
|
||
function MainMenu:createMainMenuMinibutton(text, x, y) | ||
abyss.log("debug", "Loading mini button: " .. text) | ||
local result = abyss.createButton(SystemFonts.FntRidiculous, ButtonDefs.SprButtonShortBlank) | ||
result:setSegments(1, 1) | ||
result:setFixedSize(135, 25) | ||
result.caption = text:upper() | ||
result:setPosition(x, y) | ||
result:setTextOffset(0, -5) | ||
result:setFrameIndex("normal", 0) | ||
result:setFrameIndex("pressed", 1) | ||
return result | ||
end | ||
|
||
return MainMenu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Screen = { | ||
MAIN_MENU = 1, | ||
CREDITS = 2, | ||
} | ||
|
||
Screens = { | ||
[Screen.MAIN_MENU] = require("screens/main-menu"), | ||
[Screen.CREDITS] = require("screens/credits"), | ||
} | ||
|
||
function SetScreen(screenType) | ||
CurrentScreen = Screens[screenType]:new() | ||
end |