from os import environ

from pygame import display, image, mouse
from pygame.locals import *

from GameChild import *

class Display(GameChild):

    def __init__(self, game):
        GameChild.__init__(self, game)
        self.delegate = self.get_delegate()
        self.load_configuration()
        self.align_window()
        self.init_screen()
        self.set_caption()
        self.set_icon()
        self.set_mouse_visibility()
        self.subscribe(self.toggle_fullscreen)

    def load_configuration(self):
        config = self.get_configuration("display")
        self.centered = config["centered"]
        self.fullscreen_enabled = config["fullscreen"]
        self.caption = config["caption"]
        self.windowed_flag = config["windowed-flag"]
        self.icon_path = self.get_resource("display", "icon-path")
        self.mouse_visibility = self.get_configuration("mouse", "visible")

    def align_window(self):
        if self.centered:
            environ["SDL_VIDEO_CENTERED"] = "1"

    def init_screen(self):
        flags = 0
        if self.fullscreen_requested():
            flags = FULLSCREEN
        self.set_screen(flags)

    def fullscreen_requested(self):
        return not self.check_command_line(self.windowed_flag) and \
               self.fullscreen_enabled

    def set_screen(self, flags=0, dimensions=None):
        self.dimensions_changed = dimensions is not None
        if dimensions is None:
            if display.get_surface():
                dimensions = display.get_surface().get_size()
            else:
                dimensions = self.get_configuration("display", "dimensions")
        self.screen = display.set_mode(dimensions, flags)
        if self.dimensions_changed:
            interpolator = self.get_game().interpolator
            if interpolator.gui_enabled:
                interpolator.gui.rearrange()

    def set_caption(self):
        display.set_caption(self.caption)

    def set_icon(self):
        if self.icon_path:
            print self.icon_path
            display.set_icon(image.load(self.icon_path).convert_alpha())

    def set_mouse_visibility(self, visibility=None):
        if visibility is None:
            visibility = self.mouse_visibility
        return mouse.set_visible(visibility)

    def get_screen(self):
        return self.screen

    def get_size(self):
        return self.screen.get_size()

    def toggle_fullscreen(self, event):
        if self.delegate.compare(event, "toggle-fullscreen"):
            screen = self.screen
            cpy = screen.convert()
            self.set_screen(self.screen.get_flags() ^ FULLSCREEN)
            screen.blit(cpy, (0, 0))
from os.path import exists, join, basename, normpath, abspath
from sys import argv

from pygame import mixer, event, time
from pygame.locals import *

import Game

class GameChild:

    def __init__(self, parent=None):
        self.parent = parent
        self.game = self.get_game()

    def get_game(self):
        current = self
        while not isinstance(current, Game.Game):
            current = current.parent
        return current

    def get_configuration(self, section=None, option=None, linebreaks=True):
        config = self.game.configuration
        if option is None and section is None:
            return config
        if option and section:
            rvalue = config.get(section, option)
            if not linebreaks and isinstance(rvalue, str):
                rvalue = rvalue.replace("\n", " ")
            return rvalue
        return config.get_section(section)

    def get_input(self):
        return self.game.input

    def get_screen(self):
        return self.game.display.get_screen()

    def get_display_surface(self):
        current = self
        attribute = "display_surface"
        while not isinstance(current, Game.Game):
            if hasattr(current, attribute):
                return getattr(current, attribute)
            current = current.parent
        return current.display.get_screen()

    def get_audio(self):
        return self.game.audio

    def get_delegate(self):
        return self.game.delegate

    def get_resource(self, path_or_section, option=None):
        config = self.get_configuration()
        rel_path = path_or_section
        if option is not None:
            rel_path = config.get(path_or_section, option)
        if rel_path:
            for root in config.get("setup", "resource-search-path"):
                if self.is_shared_mode() and not self.is_absolute_path(root):
                    continue
                path = join(root, rel_path)
                if exists(path):
                    return path
        self.print_debug("Couldn't find resource: {0} {1}".\
                                   format(path_or_section, option))

    def is_shared_mode(self):
        return self.check_command_line("s")

    def check_command_line(self, flag):
        return "-" + flag in argv

    def print_debug(self, statement):
        if self.is_debug_mode():
            print statement

    def is_debug_mode(self):
        return self.check_command_line("d")

    def is_absolute_path(self, path):
        return normpath(path) == abspath(path)

    def subscribe(self, callback, kind=None):
        self.game.delegate.add_subscriber(callback, kind)

    def unsubscribe(self, callback, kind=None):
        self.game.delegate.remove_subscriber(callback, kind)
import cProfile
from time import strftime
from os import mkdir
from os.path import join, exists

from GameChild import GameChild

class Profile(cProfile.Profile, GameChild):

    def __init__(self, parent):
        GameChild.__init__(self, parent)
        cProfile.Profile.__init__(self)
        if self.requested():
            self.enable()

    def requested(self):
        return self.check_command_line("p")

    def end(self):
        if self.requested():
            root = "stat/"
            if not exists(root):
                mkdir(root)
            self.disable()
            self.create_stats()
            self.dump_stats(join(root, strftime("%Y%m%d-%H%M_%S.stat")))
18.97.14.88
18.97.14.88
18.97.14.88
 
July 18, 2022


A new era ‼

Our infrastructure has recently upgraded ‼

Nugget Communications Bureau 👍

You've never emailed like this before ‼

Roundcube

Webmail software for reading and sending email from @nugget.fun and @shampoo.ooo addresses.

Mailman3

Email discussion lists, modernized with likes and emojis. It can be used for announcements and newsletters in addition to discussions. See lists for Picture Processing or Scrapeboard. Nowadays, people use Discord, but you really don't have to!

FreshRSS

With this hidden in plain sight, old technology, even regular people like you and me can start our own newspaper or social media feed.

Nugget Streaming Media 👍

The content you crave ‼

HLS

A live streaming, video format based on M3U playlists that can be played with HTML5.

RTMP

A plugin for Nginx can receive streaming video from ffmpeg or OBS and forward it as an RTMP stream to sites like Youtube and Twitch or directly to VLC.


Professional ‼

Nugget Productivity Suite 👍

Unleash your potential ‼

Kanboard

Virtual index cards you can use to gamify your daily grind.

Gitea

Grab whatever game code you want, share your edits, and report bugs.

Nugget Security 👍

The real Turing test ‼

Fail2ban

Banning is even more fun when it's automated.

Spamassassin

The documentation explains, "an email which mentions rolex watches, Viagra, porn, and debt all in one" will probably be considered spam.

GoAccess

Display HTTP requests in real time, so you can watch bots try to break into WordPress.

Nugget Entertainment Software 👍

The best in gaming entertainment ‼

Emoticon vs. Rainbow

With everything upgraded to the bleeding edge, this HTML4 game is running better than ever.


Zoom ‼

The game engine I've been working on, SPACE BOX, is now able to export to web, so I'm planning on turning nugget.fun into a games portal by releasing my games on it and adding an accounts system. The upgraded server and software will make it easier to create and maintain. I'm also thinking of using advertising and subscriptions to support the portal, so some of these services, like webmail or the RSS reader, may be offered to accounts that upgrade to a paid subscription.