Best Testkube code snippet using ui.Logo
main_menu.go
Source:main_menu.go
...38 copyright2X, copyright2Y = 400, 52539 od2LabelX, od2LabelY = 400, 58040 tcpOptionsX, tcpOptionsY = 400, 2341 joinGameX, joinGameY = 400, 19042 diabloLogoX, diabloLogoY = 400, 12043 exitDiabloBtnX, exitDiabloBtnY = 264, 53544 creditBtnX, creditBtnY = 264, 50545 cineBtnX, cineBtnY = 401, 50546 singlePlayerBtnX, singlePlayerBtnY = 264, 29047 githubBtnX, githubBtnY = 264, 40048 mapTestBtnX, mapTestBtnY = 264, 44049 tcpBtnX, tcpBtnY = 33, 54350 srvCancelBtnX, srvCancelBtnY = 285, 30551 srvOkBtnX, srvOkBtnY = 420, 30552 multiplayerBtnX, multiplayerBtnY = 264, 33053 tcpNetBtnX, tcpNetBtnY = 264, 28054 networkCancelBtnX, networkCancelBtnY = 264, 54055 tcpHostBtnX, tcpHostBtnY = 264, 20056 tcpJoinBtnX, tcpJoinBtnY = 264, 24057 errorLabelX, errorLabelY = 400, 25058 machineIPX, machineIPY = 400, 9059)60const (61 white = 0xffffffff62 lightYellow = 0xffff8cff63 gold = 0xd8c480ff64 red = 0xff0000ff65)66const (67 joinGameCharacterFilter = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890._:"68)69const (70 logPrefix = "Game Screen"71)72// BuildInfo contains information about the current build73type BuildInfo struct {74 Branch, Commit string75}76// CreateMainMenu creates an instance of MainMenu77func CreateMainMenu(78 navigator d2interface.Navigator,79 asset *d2asset.AssetManager,80 renderer d2interface.Renderer,81 inputManager d2interface.InputManager,82 audioProvider d2interface.AudioProvider,83 ui *d2ui.UIManager,84 buildInfo BuildInfo,85 l d2util.LogLevel,86 errorMessageOptional ...string,87) (*MainMenu, error) {88 heroStateFactory, err := d2hero.NewHeroStateFactory(asset)89 if err != nil {90 return nil, err91 }92 mainMenu := &MainMenu{93 asset: asset,94 screenMode: ScreenModeUnknown,95 leftButtonHeld: true,96 renderer: renderer,97 inputManager: inputManager,98 audioProvider: audioProvider,99 navigator: navigator,100 buildInfo: buildInfo,101 uiManager: ui,102 heroState: heroStateFactory,103 }104 mainMenu.Logger = d2util.NewLogger()105 mainMenu.Logger.SetPrefix(logPrefix)106 mainMenu.Logger.SetLevel(l)107 if len(errorMessageOptional) != 0 {108 mainMenu.errorLabel = ui.NewLabel(d2resource.FontFormal12, d2resource.PaletteUnits)109 mainMenu.errorLabel.SetText(errorMessageOptional[0])110 }111 return mainMenu, nil112}113// MainMenu represents the main menu114type MainMenu struct {115 tcpIPBackground *d2ui.Sprite116 trademarkBackground *d2ui.Sprite117 background *d2ui.Sprite118 diabloLogoLeft *d2ui.Sprite119 diabloLogoRight *d2ui.Sprite120 diabloLogoLeftBack *d2ui.Sprite121 diabloLogoRightBack *d2ui.Sprite122 serverIPBackground *d2ui.Sprite123 singlePlayerButton *d2ui.Button124 multiplayerButton *d2ui.Button125 githubButton *d2ui.Button126 exitDiabloButton *d2ui.Button127 creditsButton *d2ui.Button128 cinematicsButton *d2ui.Button129 mapTestButton *d2ui.Button130 networkTCPIPButton *d2ui.Button131 networkCancelButton *d2ui.Button132 btnTCPIPCancel *d2ui.Button133 btnTCPIPHostGame *d2ui.Button134 btnTCPIPJoinGame *d2ui.Button135 btnServerIPCancel *d2ui.Button136 btnServerIPOk *d2ui.Button137 copyrightLabel *d2ui.Label138 copyrightLabel2 *d2ui.Label139 openDiabloLabel *d2ui.Label140 versionLabel *d2ui.Label141 commitLabel *d2ui.Label142 tcpIPOptionsLabel *d2ui.Label143 tcpJoinGameLabel *d2ui.Label144 machineIP *d2ui.Label145 errorLabel *d2ui.Label146 tcpJoinGameEntry *d2ui.TextBox147 screenMode mainMenuScreenMode148 leftButtonHeld bool149 asset *d2asset.AssetManager150 inputManager d2interface.InputManager151 renderer d2interface.Renderer152 audioProvider d2interface.AudioProvider153 scriptEngine *d2script.ScriptEngine // nolint:structcheck,unused // it will be used...154 navigator d2interface.Navigator155 uiManager *d2ui.UIManager156 heroState *d2hero.HeroStateFactory157 buildInfo BuildInfo158 *d2util.Logger159}160// OnLoad is called to load the resources for the main menu161func (v *MainMenu) OnLoad(loading d2screen.LoadingState) {162 v.audioProvider.PlayBGM(d2resource.BGMTitle)163 loading.Progress(twentyPercent)164 v.createLabels(loading)165 v.loadBackgroundSprites()166 v.createLogos(loading)167 v.createButtons(loading)168 v.tcpJoinGameEntry = v.uiManager.NewTextbox()169 v.tcpJoinGameEntry.SetPosition(joinGameDialogX, joinGameDialogY)170 v.tcpJoinGameEntry.SetFilter(joinGameCharacterFilter)171 loading.Progress(ninetyPercent)172 if v.screenMode == ScreenModeUnknown {173 v.SetScreenMode(ScreenModeTrademark)174 } else {175 v.SetScreenMode(ScreenModeMainMenu)176 }177 if err := v.inputManager.BindHandler(v); err != nil {178 v.Error("failed to add main menu as event handler")179 }180}181func (v *MainMenu) loadBackgroundSprites() {182 var err error183 v.background, err = v.uiManager.NewSprite(d2resource.GameSelectScreen, d2resource.PaletteSky)184 if err != nil {185 v.Error(err.Error())186 }187 v.background.SetPosition(backgroundX, backgroundY)188 v.trademarkBackground, err = v.uiManager.NewSprite(d2resource.TrademarkScreen, d2resource.PaletteSky)189 if err != nil {190 v.Error(err.Error())191 }192 v.trademarkBackground.SetPosition(backgroundX, backgroundY)193 v.tcpIPBackground, err = v.uiManager.NewSprite(d2resource.TCPIPBackground, d2resource.PaletteSky)194 if err != nil {195 v.Error(err.Error())196 }197 v.tcpIPBackground.SetPosition(backgroundX, backgroundY)198 v.serverIPBackground, err = v.uiManager.NewSprite(d2resource.PopUpOkCancel, d2resource.PaletteFechar)199 if err != nil {200 v.Error(err.Error())201 }202 v.serverIPBackground.SetPosition(serverIPbackgroundX, serverIPbackgroundY)203}204func (v *MainMenu) createLabels(loading d2screen.LoadingState) {205 v.versionLabel = v.uiManager.NewLabel(d2resource.FontFormal12, d2resource.PaletteStatic)206 v.versionLabel.Alignment = d2ui.HorizontalAlignRight207 v.versionLabel.SetText("OpenDiablo2 - " + v.buildInfo.Branch)208 v.versionLabel.Color[0] = rgbaColor(white)209 v.versionLabel.SetPosition(versionLabelX, versionLabelY)210 v.commitLabel = v.uiManager.NewLabel(d2resource.FontFormal10, d2resource.PaletteStatic)211 v.commitLabel.Alignment = d2ui.HorizontalAlignLeft212 v.commitLabel.SetText(v.buildInfo.Commit)213 v.commitLabel.Color[0] = rgbaColor(white)214 v.commitLabel.SetPosition(commitLabelX, commitLabelY)215 v.copyrightLabel = v.uiManager.NewLabel(d2resource.FontFormal12, d2resource.PaletteStatic)216 v.copyrightLabel.Alignment = d2ui.HorizontalAlignCenter217 v.copyrightLabel.SetText(v.asset.TranslateLabel(d2enum.CopyrightLabel))218 v.copyrightLabel.Color[0] = rgbaColor(lightBrown)219 v.copyrightLabel.SetPosition(copyrightX, copyrightY)220 loading.Progress(thirtyPercent)221 v.copyrightLabel2 = v.uiManager.NewLabel(d2resource.FontFormal12, d2resource.PaletteStatic)222 v.copyrightLabel2.Alignment = d2ui.HorizontalAlignCenter223 v.copyrightLabel2.SetText(v.asset.TranslateLabel(d2enum.AllRightsReservedLabel))224 v.copyrightLabel2.Color[0] = rgbaColor(lightBrown)225 v.copyrightLabel2.SetPosition(copyright2X, copyright2Y)226 v.openDiabloLabel = v.uiManager.NewLabel(d2resource.FontFormal10, d2resource.PaletteStatic)227 v.openDiabloLabel.Alignment = d2ui.HorizontalAlignCenter228 v.openDiabloLabel.SetText("OpenDiablo2 is neither developed by, nor endorsed by Blizzard or its parent company Activision")229 v.openDiabloLabel.Color[0] = rgbaColor(lightYellow)230 v.openDiabloLabel.SetPosition(od2LabelX, od2LabelY)231 loading.Progress(fiftyPercent)232 v.tcpIPOptionsLabel = v.uiManager.NewLabel(d2resource.Font42, d2resource.PaletteUnits)233 v.tcpIPOptionsLabel.SetPosition(tcpOptionsX, tcpOptionsY)234 v.tcpIPOptionsLabel.Alignment = d2ui.HorizontalAlignCenter235 v.tcpIPOptionsLabel.SetText(v.asset.TranslateLabel(d2enum.TCPIPOptionsLabel))236 v.tcpJoinGameLabel = v.uiManager.NewLabel(d2resource.Font16, d2resource.PaletteUnits)237 v.tcpJoinGameLabel.Alignment = d2ui.HorizontalAlignCenter238 v.tcpJoinGameLabel.SetText(strings.Join(d2util.SplitIntoLinesWithMaxWidth(v.asset.TranslateLabel(d2enum.TCPIPEnterHostIPLabel), 27), "\n"))239 v.tcpJoinGameLabel.Color[0] = rgbaColor(gold)240 v.tcpJoinGameLabel.SetPosition(joinGameX, joinGameY)241 v.machineIP = v.uiManager.NewLabel(d2resource.Font24, d2resource.PaletteUnits)242 v.machineIP.Alignment = d2ui.HorizontalAlignCenter243 v.machineIP.SetText(v.asset.TranslateLabel(d2enum.TCPIPYourIPLabel) + "\n" + v.getLocalIP())244 v.machineIP.Color[0] = rgbaColor(lightYellow)245 v.machineIP.SetPosition(machineIPX, machineIPY)246 if v.errorLabel != nil {247 v.errorLabel.SetPosition(errorLabelX, errorLabelY)248 v.errorLabel.Alignment = d2ui.HorizontalAlignCenter249 v.errorLabel.Color[0] = rgbaColor(red)250 }251}252func (v *MainMenu) createLogos(loading d2screen.LoadingState) {253 var err error254 v.diabloLogoLeft, err = v.uiManager.NewSprite(d2resource.Diablo2LogoFireLeft, d2resource.PaletteUnits)255 if err != nil {256 v.Error(err.Error())257 }258 v.diabloLogoLeft.SetEffect(d2enum.DrawEffectModulate)259 v.diabloLogoLeft.PlayForward()260 v.diabloLogoLeft.SetPosition(diabloLogoX, diabloLogoY)261 loading.Progress(sixtyPercent)262 v.diabloLogoRight, err = v.uiManager.NewSprite(d2resource.Diablo2LogoFireRight, d2resource.PaletteUnits)263 if err != nil {264 v.Error(err.Error())265 }266 v.diabloLogoRight.SetEffect(d2enum.DrawEffectModulate)267 v.diabloLogoRight.PlayForward()268 v.diabloLogoRight.SetPosition(diabloLogoX, diabloLogoY)269 v.diabloLogoLeftBack, err = v.uiManager.NewSprite(d2resource.Diablo2LogoBlackLeft, d2resource.PaletteUnits)270 if err != nil {271 v.Error(err.Error())272 }273 v.diabloLogoLeftBack.SetPosition(diabloLogoX, diabloLogoY)274 v.diabloLogoRightBack, err = v.uiManager.NewSprite(d2resource.Diablo2LogoBlackRight, d2resource.PaletteUnits)275 if err != nil {276 v.Error(err.Error())277 }278 v.diabloLogoRightBack.SetPosition(diabloLogoX, diabloLogoY)279}280func (v *MainMenu) createButtons(loading d2screen.LoadingState) {281 v.exitDiabloButton = v.uiManager.NewButton(d2ui.ButtonTypeWide, v.asset.TranslateLabel(d2enum.ExitGameLabel))282 v.exitDiabloButton.SetPosition(exitDiabloBtnX, exitDiabloBtnY)283 v.exitDiabloButton.OnActivated(func() { v.onExitButtonClicked() })284 v.creditsButton = v.uiManager.NewButton(d2ui.ButtonTypeShort, v.asset.TranslateLabel(d2enum.CreditsLabel))285 v.creditsButton.SetPosition(creditBtnX, creditBtnY)286 v.creditsButton.OnActivated(func() { v.onCreditsButtonClicked() })287 v.cinematicsButton = v.uiManager.NewButton(d2ui.ButtonTypeShort, v.asset.TranslateLabel(d2enum.CinematicsLabel))288 v.cinematicsButton.SetPosition(cineBtnX, cineBtnY)289 v.cinematicsButton.OnActivated(func() { v.onCinematicsButtonClicked() })290 loading.Progress(seventyPercent)291 v.singlePlayerButton = v.uiManager.NewButton(d2ui.ButtonTypeWide, v.asset.TranslateLabel(d2enum.SinglePlayerLabel))292 v.singlePlayerButton.SetPosition(singlePlayerBtnX, singlePlayerBtnY)293 v.singlePlayerButton.OnActivated(func() { v.onSinglePlayerClicked() })294 v.githubButton = v.uiManager.NewButton(d2ui.ButtonTypeWide, "PROJECT WEBSITE")295 v.githubButton.SetPosition(githubBtnX, githubBtnY)296 v.githubButton.OnActivated(func() { v.onGithubButtonClicked() })297 v.mapTestButton = v.uiManager.NewButton(d2ui.ButtonTypeWide, "MAP ENGINE TEST")298 v.mapTestButton.SetPosition(mapTestBtnX, mapTestBtnY)299 v.mapTestButton.OnActivated(func() { v.onMapTestClicked() })300 v.btnTCPIPCancel = v.uiManager.NewButton(d2ui.ButtonTypeMedium,301 v.asset.TranslateLabel(d2enum.CancelLabel))302 v.btnTCPIPCancel.SetPosition(tcpBtnX, tcpBtnY)303 v.btnTCPIPCancel.OnActivated(func() { v.onTCPIPCancelClicked() })304 v.btnServerIPCancel = v.uiManager.NewButton(d2ui.ButtonTypeOkCancel, v.asset.TranslateLabel(d2enum.CancelLabel))305 v.btnServerIPCancel.SetPosition(srvCancelBtnX, srvCancelBtnY)306 v.btnServerIPCancel.OnActivated(func() { v.onBtnTCPIPCancelClicked() })307 v.btnServerIPOk = v.uiManager.NewButton(d2ui.ButtonTypeOkCancel, v.asset.TranslateString(d2enum.OKLabel))308 v.btnServerIPOk.SetPosition(srvOkBtnX, srvOkBtnY)309 v.btnServerIPOk.OnActivated(func() { v.onBtnTCPIPOkClicked() })310 v.createMultiplayerMenuButtons()311 loading.Progress(eightyPercent)312}313func (v *MainMenu) createMultiplayerMenuButtons() {314 v.multiplayerButton = v.uiManager.NewButton(d2ui.ButtonTypeWide,315 v.asset.TranslateLabel(d2enum.OtherMultiplayerLabel))316 v.multiplayerButton.SetPosition(multiplayerBtnX, multiplayerBtnY)317 v.multiplayerButton.OnActivated(func() { v.onMultiplayerClicked() })318 v.networkTCPIPButton = v.uiManager.NewButton(d2ui.ButtonTypeWide, v.asset.TranslateLabel(d2enum.TCPIPGameLabel))319 v.networkTCPIPButton.SetPosition(tcpNetBtnX, tcpNetBtnY)320 v.networkTCPIPButton.OnActivated(func() { v.onNetworkTCPIPClicked() })321 v.networkCancelButton = v.uiManager.NewButton(d2ui.ButtonTypeWide,322 v.asset.TranslateLabel(d2enum.CancelLabel))323 v.networkCancelButton.SetPosition(networkCancelBtnX, networkCancelBtnY)324 v.networkCancelButton.OnActivated(func() { v.onNetworkCancelClicked() })325 v.btnTCPIPHostGame = v.uiManager.NewButton(d2ui.ButtonTypeWide, v.asset.TranslateLabel(d2enum.TCPIPHostGameLabel))326 v.btnTCPIPHostGame.SetPosition(tcpHostBtnX, tcpHostBtnY)327 v.btnTCPIPHostGame.OnActivated(func() { v.onTCPIPHostGameClicked() })328 v.btnTCPIPJoinGame = v.uiManager.NewButton(d2ui.ButtonTypeWide, v.asset.TranslateLabel(d2enum.TCPIPJoinGameLabel))329 v.btnTCPIPJoinGame.SetPosition(tcpJoinBtnX, tcpJoinBtnY)330 v.btnTCPIPJoinGame.OnActivated(func() { v.onTCPIPJoinGameClicked() })331}332func (v *MainMenu) onMapTestClicked() {333 v.navigator.ToMapEngineTest(0, 1)334}335func (v *MainMenu) onSinglePlayerClicked() {336 v.SetScreenMode(ScreenModeUnknown)337 if v.heroState.HasGameStates() {338 // Go here only if existing characters are available to select339 v.navigator.ToCharacterSelect(d2clientconnectiontype.Local, v.tcpJoinGameEntry.GetText())340 } else {341 v.navigator.ToSelectHero(d2clientconnectiontype.Local, v.tcpJoinGameEntry.GetText())342 }343}344func (v *MainMenu) onGithubButtonClicked() {345 url := "https://www.github.com/OpenDiablo2/OpenDiablo2"346 var err error347 switch runtime.GOOS {348 case "linux":349 err = exec.Command("xdg-open", url).Start()350 case "windows":351 err = exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start()352 case "darwin":353 err = exec.Command("open", url).Start()354 default:355 err = fmt.Errorf("unsupported platform")356 }357 if err != nil {358 v.Error(err.Error())359 }360}361func (v *MainMenu) onExitButtonClicked() {362 os.Exit(0)363}364func (v *MainMenu) onCreditsButtonClicked() {365 v.navigator.ToCredits()366}367func (v *MainMenu) onCinematicsButtonClicked() {368 v.navigator.ToCinematics()369}370// Render renders the main menu371func (v *MainMenu) Render(screen d2interface.Surface) {372 v.renderBackgrounds(screen)373 v.renderLogos(screen)374 v.renderLabels(screen)375}376func (v *MainMenu) renderBackgrounds(screen d2interface.Surface) {377 switch v.screenMode {378 case ScreenModeTrademark:379 v.trademarkBackground.RenderSegmented(screen, 4, 3, 0)380 case ScreenModeServerIP:381 v.tcpIPBackground.RenderSegmented(screen, 4, 3, 0)382 v.serverIPBackground.RenderSegmented(screen, 2, 1, 0)383 case ScreenModeTCPIP:384 v.tcpIPBackground.RenderSegmented(screen, 4, 3, 0)385 default:386 v.background.RenderSegmented(screen, 4, 3, 0)387 }388}389func (v *MainMenu) renderLogos(screen d2interface.Surface) {390 switch v.screenMode {391 case ScreenModeTrademark, ScreenModeMainMenu, ScreenModeMultiplayer:392 v.diabloLogoLeftBack.Render(screen)393 v.diabloLogoRightBack.Render(screen)394 v.diabloLogoLeft.Render(screen)395 v.diabloLogoRight.Render(screen)396 }397}398func (v *MainMenu) renderLabels(screen d2interface.Surface) {399 switch v.screenMode {400 case ScreenModeServerIP:401 v.tcpIPOptionsLabel.Render(screen)402 v.tcpJoinGameLabel.Render(screen)403 v.machineIP.Render(screen)404 case ScreenModeTCPIP:405 v.tcpIPOptionsLabel.Render(screen)406 v.machineIP.Render(screen)407 case ScreenModeTrademark:408 v.copyrightLabel.Render(screen)409 v.copyrightLabel2.Render(screen)410 if v.errorLabel != nil {411 v.errorLabel.Render(screen)412 }413 case ScreenModeMainMenu:414 v.openDiabloLabel.Render(screen)415 v.versionLabel.Render(screen)416 v.commitLabel.Render(screen)417 }418}419// Advance runs the update logic on the main menu420func (v *MainMenu) Advance(tickTime float64) error {421 switch v.screenMode {422 case ScreenModeMainMenu, ScreenModeTrademark, ScreenModeMultiplayer:423 if err := v.diabloLogoLeftBack.Advance(tickTime); err != nil {424 return err425 }426 if err := v.diabloLogoRightBack.Advance(tickTime); err != nil {427 return err428 }429 if err := v.diabloLogoLeft.Advance(tickTime); err != nil {430 return err431 }432 if err := v.diabloLogoRight.Advance(tickTime); err != nil {433 return err434 }435 }436 return nil437}438// OnMouseButtonDown is called when a mouse button is clicked439func (v *MainMenu) OnMouseButtonDown(event d2interface.MouseEvent) bool {440 if v.screenMode == ScreenModeTrademark && event.Button() == d2enum.MouseButtonLeft {441 v.SetScreenMode(ScreenModeMainMenu)442 return true443 }444 return false445}446func (v *MainMenu) onEscapePressed(event d2interface.KeyEvent, mode mainMenuScreenMode) {...
uilogo.go
Source:uilogo.go
...26 "github.com/thinkofdeath/steven/resource"27 "github.com/thinkofdeath/steven/ui"28 "github.com/thinkofdeath/steven/ui/scene"29)30type uiLogo struct {31 scene *scene.Type32 text *ui.Text33 origX float6434 textBaseScale float6435}36var (37 r = rand.New(rand.NewSource(time.Now().UnixNano()))38 logoTexture = "blocks/cobblestone"39 logoTargetTexture = "blocks/cobblestone"40 logoText string41 logoTextTimer float6442 logoLayers [2][]*ui.Image43 logoTimer, logoTransTimer float6444 stevenLogo string45)46func (u *uiLogo) init(scene *scene.Type) {47 if logoText == "" {48 nextLogoText()49 }50 if logoTexture == "" {51 nextLogoTexture()52 logoTexture = logoTargetTexture53 }54 readStevenLogo()55 u.scene = scene56 row := 057 tex, tex2 := render.GetTexture(logoTexture), render.GetTexture(logoTargetTexture)58 titleBox := ui.NewContainer(0, 8, 0, 0).Attach(ui.Top, ui.Center)59 logoTimer = r.Float64() * 60 * 3060 logoTransTimer = 12061 for _, line := range strings.Split(stevenLogo, "\n") {62 if line == "" {63 continue64 }65 for i, r := range line {66 if r == ' ' {67 continue68 }69 x, y := i*4, row*870 rr, gg, bb := 255, 255, 25571 if r != ':' {72 rr, gg, bb = 170, 170, 17073 }74 shadow := ui.NewImage(75 render.GetTexture("solid"),76 float64(x+2), float64(y+4), 4, 8,77 float64(x%16)/16.0, float64(y%16)/16.0, 4/16.0, 8/16.0,78 0, 0, 0,79 )80 shadow.SetA(100)81 shadow.AttachTo(titleBox)82 u.scene.AddDrawable(shadow)83 img := ui.NewImage(84 tex,85 float64(x), float64(y), 4, 8,86 float64(x%16)/16.0, float64(y%16)/16.0, 4/16.0, 8/16.0,87 rr, gg, bb,88 )89 img.AttachTo(titleBox)90 u.scene.AddDrawable(img)91 logoLayers[0] = append(logoLayers[0], img)92 img = ui.NewImage(93 tex2,94 float64(x), float64(y), 4, 8,95 float64(x%16)/16.0, float64(y%16)/16.0, 4/16.0, 8/16.0,96 rr, gg, bb,97 )98 img.AttachTo(titleBox)99 img.SetA(0)100 u.scene.AddDrawable(img)101 logoLayers[1] = append(logoLayers[1], img)102 if titleBox.Width() < float64(x+4) {103 titleBox.SetWidth(float64(x + 4))104 }105 }106 row++107 }108 titleBox.SetHeight(float64(row) * 8.0)109 txt := ui.NewText(logoText, 0, -8, 255, 255, 0).Attach(ui.Bottom, ui.Right)110 txt.AttachTo(titleBox)111 txt.SetRotation(-math.Pi / 8)112 u.scene.AddDrawable(txt)113 u.text = txt114 width, _ := txt.Size()115 u.textBaseScale = 300 / width116 if u.textBaseScale > 1 {117 u.textBaseScale = 1118 }119 txt.SetX((-txt.Width / 2) * u.textBaseScale)120 u.origX = txt.X()121}122func (u *uiLogo) tick(delta float64) {123 if logoTimer > 0 {124 logoTimer -= delta125 } else if logoTransTimer < 0 {126 logoTransTimer = 120127 logoTimer = r.Float64() * 60 * 30128 readStevenLogo()129 logoTexture = logoTargetTexture130 nextLogoTexture()131 nextLogoText()132 u.text.Update(logoText)133 width, _ := u.text.Size()134 u.textBaseScale = 300 / width135 if u.textBaseScale > 1 {136 u.textBaseScale = 1137 }138 u.text.SetX((-u.text.Width / 2) * u.textBaseScale)139 u.origX = u.text.X()140 } else {141 logoTransTimer -= delta142 }143 tex, tex2 := render.GetTexture(logoTexture), render.GetTexture(logoTargetTexture)144 for i := range logoLayers[0] {145 logoLayers[0][i].SetTexture(tex)146 logoLayers[1][i].SetTexture(tex2)147 logoLayers[0][i].SetA(int(255 * (logoTransTimer / 120)))148 logoLayers[1][i].SetA(int(255 * (1 - (logoTransTimer / 120))))149 }150 logoTextTimer += delta151 if logoTextTimer > 60 {152 logoTextTimer -= 60153 }154 off := (logoTextTimer / 30)155 if off > 1.0 {156 off = 2.0 - off157 }158 off = (math.Cos(off*math.Pi) + 1) / 2159 u.text.SetScaleX((0.7 + (off / 3)) * u.textBaseScale)160 u.text.SetScaleY((0.7 + (off / 3)) * u.textBaseScale)161 u.text.SetX(u.origX * u.text.ScaleX() * u.textBaseScale)162}163func nextLogoText() {164 lines := make([]string, len(stevenLogoLines))165 copy(lines, stevenLogoLines)166 rs, _ := resource.OpenAll("minecraft", "texts/splashes.txt")167 for _, r := range rs {168 func() {169 defer r.Close()170 s := bufio.NewScanner(r)171 for s.Scan() {172 line := s.Text()173 if line != "" && !strings.ContainsRune(line, '§') {174 switch line {175 case "Now Java 6!":176 line = "Now Go!"177 case "OpenGL 2.1 (if supported)!":178 line = "OpenGL 3.2!"179 }180 lines = append(lines, line)181 }182 }183 }()184 }185 logoText = lines[r.Intn(len(lines))]186}187var stevenLogoLines = []string{188 "Your machine uses " + native.Order.String() + " byte order!",189 fmt.Sprintf("You have %d CPUs!", runtime.NumCPU()),190 fmt.Sprintf("Compiled for %s with a %s CPU!", runtime.GOOS, runtime.GOARCH),191 "Compiled with " + runtime.Version() + "!",192 fmt.Sprintf("Splash generated at %d", time.Now().Unix()),193}194func readStevenLogo() {195 r, _ := resource.Open("steven", "logo/logo.txt")196 defer r.Close()197 data, _ := ioutil.ReadAll(r)198 stevenLogo = string(data)199}200func nextLogoTexture() {201 var textures []string202 rs, _ := resource.OpenAll("steven", "logo/textures.txt")203 for _, r := range rs {204 func() {205 defer r.Close()206 s := bufio.NewScanner(r)207 for s.Scan() {208 texture := s.Text()209 textures = append(textures, texture)210 }211 }()212 }213 if len(textures) > 0 {214 logoTargetTexture = textures[r.Intn(len(textures))]...
start.go
Source:start.go
...14 probe *env.Probe15 sl *shadow.PointLight16 bRun *vui.Button17 lStat *vui.Label18 nLogoParent *vscene.Node19 ui *vui.UIView20 rSize *vui.RadioGroup21}22func (w *logoWindow) Dispose() {23 if w.env != nil {24 w.env.Dispose()25 w.probe.Dispose()26 w.env = nil27 }28}29type shrinkAmim struct {30 started float6431 m *maze32 done bool33}34func (s *shrinkAmim) Process(pi *vscene.ProcessInfo) {35 if s.done {36 pi.Visible = false37 return38 }39 t := pi.Time - s.started40 sf := float32(1 - t)41 pi.World = pi.World.Mul4(mgl32.Scale3D(sf, sf, sf))42 if sf < 0.5 && s.m != nil {43 s.done = true44 s.m.switchScene()45 }46}47func (w *logoWindow) startRun() {48 sa := &shrinkAmim{started: app.mainWnd.GetSceneTime()}49 size := 450 switch w.rSize.Value {51 case 1:52 size = 853 case 2:54 size = 1255 }56 go buildMaze(sa, size)57 app.mainWnd.Scene.Update(func() {58 w.ui.Hide()59 app.mainWnd.Ui.Children = nil60 w.nLogoParent.Ctrl = sa61 })62 if app.fps {63 fpsDebug := vdebug.NewFPSTimer(app.mainWnd, app.theme)64 fpsDebug.AddGPUTiming()65 }66}67func buildStartScene() *logoWindow {68 lw := &logoWindow{}69 rw := app.mainWnd70 // Load envhdr/studio.hdr71 lw.env = vapp.MustLoadAsset("envhdr/studio.hdr",72 func(content []byte) (asset interface{}, err error) {73 return env.NewEquiRectBGNode(vapp.Ctx, vapp.Dev, 100, "hdr", content), nil74 }).(*env.EquiRectBGNode)75 // Add loaded background to scene76 rw.Env.Children = append(rw.Env.Children, vscene.NewNode(lw.env))77 nLogo := vscene.NodeFromModel(app.logoModel, 0, true)78 // We will also need a probe to reflect environment to model. Probes reflect everything outside this node inside children of this node.79 // In this case we reflect only background80 lw.probe = env.NewProbe(vapp.Ctx, vapp.Dev)81 // Create a new nodes from model and probe82 lw.nLogoParent = vscene.NewNode(nil, nLogo)83 rw.Model.Children = append(rw.Model.Children, lw.nLogoParent)84 // Assign probe to root model85 rw.Model.Ctrl = lw.probe86 // Attach camera to window (with better location that default one) and orbital control to camera87 c := vscene.NewPerspectiveCamera(1000)88 c.Position = mgl32.Vec3{1, 2, 10}89 c.Target = mgl32.Vec3{5, 0, 0}90 rw.Camera = c91 // Finally create 2 lights before UI92 // Create custom node control to turn light on / off93 nLight := vscene.NewNode(nil)94 rw.Env.Children = append(rw.Env.Children, nLight)95 // Add light96 lw.sl = shadow.NewPointLight(vscene.PointLight{Intensity: mgl32.Vec3{1.4, 1.4, 1.4}, Attenuation: mgl32.Vec3{0, 0, 0.2}}, 512)97 // Add shadow light to scene on location 1,3,3 and 4,3,3...
Logo
Using AI Code Generation
1import (2func main() {3 fmt.Println(ui.Logo())4}5import (6func main() {7 fmt.Println(ui.Logo())8}9import (10func main() {11 fmt.Println(ui.Logo())12}13import (14func main() {15 fmt.Println(ui.Logo())16}17import (18func main() {19 fmt.Println(ui.Logo())20}21import (22func main() {23 fmt.Println(ui.Logo())24}25import (26func main() {27 fmt.Println(ui.Logo())28}29import (30func main() {31 fmt.Println(ui.Logo())32}33import (34func main() {35 fmt.Println(ui.Logo())36}37import (38func main() {39 fmt.Println(ui.Logo())40}41import (42func main() {43 fmt.Println(ui.Logo())44}45import (46func main() {47 fmt.Println(ui.Logo())48}49import (
Logo
Using AI Code Generation
1import "fmt"2import "./ui"3func main() {4 ui.Logo()5}6import "fmt"7import "./ui"8func main() {9 ui.Logo()10}11import "fmt"12import "./ui"13func main() {14 ui.Logo()15}16import "fmt"17import "./ui"18func main() {19 ui.Logo()20}21import "fmt"22import "./ui"23func main() {24 ui.Logo()25}26import "fmt"27import "./ui"28func main() {29 ui.Logo()30}31import "fmt"32import "./ui"33func main() {34 ui.Logo()35}36import "fmt"37import "./ui"38func main() {39 ui.Logo()40}41import "fmt"42import "./ui"43func main() {44 ui.Logo()45}46import "fmt"47import "./ui"48func main() {49 ui.Logo()50}51import "fmt"52import "./ui"53func main() {54 ui.Logo()55}56import "fmt"57import "./ui"58func main() {59 ui.Logo()60}61import "fmt"62import "./ui"63func main() {64 ui.Logo()65}66import
Logo
Using AI Code Generation
1import "fmt"2type UI interface {3 Logo()4}5type Android struct {6}7func (a Android) Logo() {8 fmt.Println("Android logo")9}10type Ios struct {11}12func (i Ios) Logo() {13 fmt.Println("Ios logo")14}15func main() {16 ui = Android{}17 ui.Logo()18 ui = Ios{}19 ui.Logo()20}21interface {}22An empty interface may hold values of any type. (Every type implements at least zero methods.)23import "fmt"24func main() {25 var i interface{}26 describe(i)27 describe(i)28 describe(i)29}30func describe(i interface{}) {31 fmt.Printf("(%v, %T)32}33An empty interface may hold values of any type. (Every type implements at least zero methods.)34import "fmt"35func main() {36 var i interface{}37 describe(i)38 describe(i)
Logo
Using AI Code Generation
1ui.Logo()2ui.Title()3ui.Menu()4ui.Footer()5ui.Logo()6ui.Title()7ui.Menu()8ui.Footer()9ui.Logo()10ui.Title()11ui.Menu()12ui.Footer()13ui.Logo()14ui.Title()15ui.Menu()16ui.Footer()17ui.Logo()18ui.Title()19ui.Menu()20ui.Footer()21ui.Logo()22ui.Title()23ui.Menu()24ui.Footer()25ui.Logo()26ui.Title()27ui.Menu()28ui.Footer()29ui.Logo()30ui.Title()31ui.Menu()32ui.Footer()33ui.Logo()34ui.Title()
Logo
Using AI Code Generation
1import "fmt"2type UI interface {3 Logo()4}5type Android struct {6}7func (a Android) Logo() {8 fmt.Println("Android Logo")9}10type Ios struct {11}12func (i Ios) Logo() {13 fmt.Println("Ios Logo")14}15func main() {16 ui = Android{name: "Android"}17 ui.Logo()18 ui = Ios{name: "Ios"}19 ui.Logo()20}21import (22type Shape interface {23 Area() float6424}25type Circle struct {26}27func (c Circle) Area() float64 {28}29func info(s Shape) {30 fmt.Println("Area of the shape is ", s.Area())31}32func main() {33 c := Circle{radius: 5}34 info(c)35}36import (37type Shape interface {38 Area() float6439}40type Circle struct {41}42func (c Circle) Area() float64 {43}44type Rectangle struct {45}46func (r Rectangle) Area() float64 {47}
Logo
Using AI Code Generation
1import (2func main() {3 fmt.Println(ui.Logo())4}5import (6func main() {7 fmt.Println(ui.Logo())8}9import (10func main() {11 fmt.Println(ui.Logo())12}13import (14func main() {15 fmt.Println(ui.Logo())16}
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!