mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2025-02-14 04:26:44 -05:00
Updated readme. Menu updates.
This commit is contained in:
parent
e9181535be
commit
4231199459
@ -131,7 +131,7 @@ func CreateSprite(data []byte, palette Palette) *Sprite {
|
||||
func (v *Sprite) GetSize() (uint32, uint32) {
|
||||
frame := v.Frames[uint32(v.Frame)+(uint32(v.Direction)*v.FramesPerDirection)]
|
||||
for frame.Loaded == false {
|
||||
time.Sleep(time.Millisecond)
|
||||
time.Sleep(time.Millisecond * 5)
|
||||
}
|
||||
return frame.Width, frame.Height
|
||||
}
|
||||
@ -212,7 +212,7 @@ func (v *Sprite) DrawSegments(target *ebiten.Image, xSegments, ySegments, offset
|
||||
opts.ColorM = ColorToColorM(v.ColorMod)
|
||||
}
|
||||
for frame.Loaded == false {
|
||||
time.Sleep(time.Millisecond)
|
||||
time.Sleep(time.Millisecond * 5)
|
||||
}
|
||||
target.DrawImage(frame.Image, opts)
|
||||
xOffset += int32(frame.Width)
|
||||
|
@ -3,6 +3,8 @@
|
||||
[Join us on Discord!](https://discord.gg/pRy8tdc)\
|
||||
[Development Live stream](https://www.twitch.tv/essial/)
|
||||
|
||||
![Main Menu](docs/MainMenuSS.png)
|
||||
|
||||
## About this project
|
||||
|
||||
OpenDiablo2 is an ARPG game engine in the same vein of the 2000's games, and supports playing Diablo 2. The engine is written in golang and is cross platform. However, please note that this project does not ship with the assets or content required to play Diablo 2. You must have a legally purchased copy of [Diablo 2](https://us.shop.battle.net/en-us/product/diablo-ii) and its expansion [Lord of Destruction](https://us.shop.battle.net/en-us/product/diablo-ii-lord-of-destruction) installed on your computer in order to run that game on this engine. If you have an original copy of the disks, those files should work fine as well.
|
||||
|
@ -94,16 +94,18 @@ const (
|
||||
|
||||
// --- Fonts ---
|
||||
|
||||
Font6 = "/data/local/font/latin/font6"
|
||||
Font8 = "/data/local/font/latin/font8"
|
||||
Font16 = "/data/local/font/latin/font16"
|
||||
Font24 = "/data/local/font/latin/font24"
|
||||
Font30 = "/data/local/font/latin/font30"
|
||||
FontFormal12 = "/data/local/font/latin/fontformal12"
|
||||
FontFormal11 = "/data/local/font/latin/fontformal11"
|
||||
FontFormal10 = "/data/local/font/latin/fontformal10"
|
||||
FontExocet10 = "/data/local/font/latin/fontexocet10"
|
||||
FontExocet8 = "/data/local/font/latin/fontexocet8"
|
||||
Font6 = "/data/local/font/latin/font6"
|
||||
Font8 = "/data/local/font/latin/font8"
|
||||
Font16 = "/data/local/font/latin/font16"
|
||||
Font24 = "/data/local/font/latin/font24"
|
||||
Font30 = "/data/local/font/latin/font30"
|
||||
FontFormal12 = "/data/local/font/latin/fontformal12"
|
||||
FontFormal11 = "/data/local/font/latin/fontformal11"
|
||||
FontFormal10 = "/data/local/font/latin/fontformal10"
|
||||
FontExocet10 = "/data/local/font/latin/fontexocet10"
|
||||
FontExocet8 = "/data/local/font/latin/fontexocet8"
|
||||
FontSucker = "/data/local/font/latin/ReallyTheLastSucker"
|
||||
FontRediculous = "/data/local/font/latin/fontridiculous"
|
||||
|
||||
// --- UI ---
|
||||
|
||||
|
@ -1,8 +1,12 @@
|
||||
package Scenes
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"image/color"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
|
||||
"github.com/essial/OpenDiablo2/Common"
|
||||
"github.com/essial/OpenDiablo2/Palettes"
|
||||
@ -25,10 +29,14 @@ type MainMenu struct {
|
||||
diabloLogoRight *Common.Sprite
|
||||
diabloLogoLeftBack *Common.Sprite
|
||||
diabloLogoRightBack *Common.Sprite
|
||||
singlePlayerButton *UI.Button
|
||||
githubButton *UI.Button
|
||||
exitDiabloButton *UI.Button
|
||||
creditsButton *UI.Button
|
||||
cinematicsButton *UI.Button
|
||||
copyrightLabel *UI.Label
|
||||
copyrightLabel2 *UI.Label
|
||||
openDiabloLabel *UI.Label
|
||||
ShowTrademarkScreen bool
|
||||
leftButtonHeld bool
|
||||
}
|
||||
@ -63,6 +71,13 @@ func (v *MainMenu) Load() []func() {
|
||||
v.copyrightLabel2.Color = color.RGBA{188, 168, 140, 255}
|
||||
v.copyrightLabel2.MoveTo(400, 525)
|
||||
},
|
||||
func() {
|
||||
v.openDiabloLabel = UI.CreateLabel(v.fileProvider, ResourcePaths.FontFormal10, Palettes.Static)
|
||||
v.openDiabloLabel.Alignment = UI.LabelAlignCenter
|
||||
v.openDiabloLabel.SetText("OpenDiablo2 is neither developed by, nor endorsed by Blizzard or its parent company Activision")
|
||||
v.openDiabloLabel.Color = color.RGBA{255, 255, 140, 255}
|
||||
v.openDiabloLabel.MoveTo(400, 580)
|
||||
},
|
||||
func() {
|
||||
v.background = v.fileProvider.LoadSprite(ResourcePaths.GameSelectScreen, Palettes.Sky)
|
||||
v.background.MoveTo(0, 0)
|
||||
@ -105,9 +120,51 @@ func (v *MainMenu) Load() []func() {
|
||||
v.creditsButton.OnActivated(func() { v.onCreditsButtonClicked() })
|
||||
v.uiManager.AddWidget(v.creditsButton)
|
||||
},
|
||||
func() {
|
||||
v.cinematicsButton = UI.CreateButton(UI.ButtonTypeShort, v.fileProvider, "CINEMATICS")
|
||||
v.cinematicsButton.MoveTo(401, 505)
|
||||
v.cinematicsButton.SetVisible(!v.ShowTrademarkScreen)
|
||||
v.uiManager.AddWidget(v.cinematicsButton)
|
||||
},
|
||||
func() {
|
||||
v.singlePlayerButton = UI.CreateButton(UI.ButtonTypeWide, v.fileProvider, "SINGLE PLAYER")
|
||||
v.singlePlayerButton.MoveTo(264, 290)
|
||||
v.singlePlayerButton.SetVisible(!v.ShowTrademarkScreen)
|
||||
v.uiManager.AddWidget(v.singlePlayerButton)
|
||||
},
|
||||
func() {
|
||||
v.githubButton = UI.CreateButton(UI.ButtonTypeWide, v.fileProvider, "PROJECT WEBSITE")
|
||||
v.githubButton.MoveTo(264, 330)
|
||||
v.githubButton.SetVisible(!v.ShowTrademarkScreen)
|
||||
v.githubButton.OnActivated(func() { v.onGithubButtonClicked() })
|
||||
v.uiManager.AddWidget(v.githubButton)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func openbrowser(url string) {
|
||||
var err error
|
||||
|
||||
switch runtime.GOOS {
|
||||
case "linux":
|
||||
err = exec.Command("xdg-open", url).Start()
|
||||
case "windows":
|
||||
err = exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start()
|
||||
case "darwin":
|
||||
err = exec.Command("open", url).Start()
|
||||
default:
|
||||
err = fmt.Errorf("unsupported platform")
|
||||
}
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (v *MainMenu) onGithubButtonClicked() {
|
||||
openbrowser("https://www.github.com/essial/OpenDiablo2")
|
||||
}
|
||||
|
||||
func (v *MainMenu) onExitButtonClicked() {
|
||||
os.Exit(0)
|
||||
}
|
||||
@ -137,7 +194,7 @@ func (v *MainMenu) Render(screen *ebiten.Image) {
|
||||
v.copyrightLabel.Draw(screen)
|
||||
v.copyrightLabel2.Draw(screen)
|
||||
} else {
|
||||
|
||||
v.openDiabloLabel.Draw(screen)
|
||||
}
|
||||
}
|
||||
|
||||
@ -149,6 +206,9 @@ func (v *MainMenu) Update(tickTime float64) {
|
||||
v.ShowTrademarkScreen = false
|
||||
v.exitDiabloButton.SetVisible(true)
|
||||
v.creditsButton.SetVisible(true)
|
||||
v.cinematicsButton.SetVisible(true)
|
||||
v.singlePlayerButton.SetVisible(true)
|
||||
v.githubButton.SetVisible(true)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ type ButtonLayout struct {
|
||||
// ButtonLayouts define the type of buttons you can have
|
||||
var ButtonLayouts = map[ButtonType]ButtonLayout{
|
||||
ButtonTypeWide: {2, 1, ResourcePaths.WideButtonBlank, Palettes.Units, false, 0, -1, ResourcePaths.FontExocet10, nil, true},
|
||||
ButtonTypeShort: {1, 1, ResourcePaths.ShortButtonBlank, Palettes.Units, false, 0, -1, ResourcePaths.FontExocet8, nil, true},
|
||||
ButtonTypeShort: {1, 1, ResourcePaths.ShortButtonBlank, Palettes.Units, false, 0, -1, ResourcePaths.FontRediculous, nil, true},
|
||||
ButtonTypeMedium: {1, 1, ResourcePaths.MediumButtonBlank, Palettes.Units, false, 0, -1, ResourcePaths.FontExocet10, nil, true},
|
||||
/*
|
||||
{eButtonType.Wide, new ButtonLayout { XSegments = 2, ResourceName = ResourcePaths.WideButtonBlank, PaletteName = Palettes.Units } },
|
||||
@ -123,9 +123,9 @@ func CreateButton(buttonType ButtonType, fileProvider Common.FileProvider, text
|
||||
|
||||
result.normalImage, _ = ebiten.NewImage(int(result.width), int(result.height), ebiten.FilterNearest)
|
||||
result.pressedImage, _ = ebiten.NewImage(int(result.width), int(result.height), ebiten.FilterNearest)
|
||||
textWidth, textHeight := font.GetTextMetrics(text)
|
||||
textWidth, _ := font.GetTextMetrics(text)
|
||||
textX := (result.width / 2) - (textWidth / 2)
|
||||
textY := (result.height / 2) - (textHeight / 2) + 1
|
||||
textY := (result.height / 2)
|
||||
buttonSprite.MoveTo(0, 0)
|
||||
buttonSprite.Blend = true
|
||||
buttonSprite.DrawSegments(result.normalImage, buttonLayout.XSegments, buttonLayout.YSegments, buttonLayout.BaseFrame)
|
||||
|
@ -62,8 +62,8 @@ func (v *Font) GetTextMetrics(text string) (width, height uint32) {
|
||||
ch := text[i]
|
||||
metric := v.metrics[uint8(ch)]
|
||||
width += uint32(metric.Width)
|
||||
_, h := v.fontSprite.GetFrameSize(int(ch))
|
||||
height = Common.Max(height, h)
|
||||
//_, h := v.fontSprite.GetFrameSize(int(ch))
|
||||
height = Common.Max(height, uint32(metric.Height))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
BIN
docs/MainMenuSS.png
Normal file
BIN
docs/MainMenuSS.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 322 KiB |
Loading…
Reference in New Issue
Block a user