This is CribbagePrefs.m in view mode; [Download] [Up]
// indent:4 tabsize:4 font:fixed-width // // The Cribbage Solitaire module. // // Copyright 1994 by David Fedchenko. All rights reserved. // #import "CribbagePrefs.h" @implementation CribbagePrefs //-------------------------------------------------------------------------- // - registerPrefs // // returns: (id) self // // Register the preferences for this game. Called automatically. // //-------------------------------------------------------------------------- - registerPrefs { const NXDefaultsVector gameDefaults = {{"Strict", "0"}, {"HighScore", "0"}, {NULL, NULL}}; NXRegisterDefaults(gameName, gameDefaults); [idStrict setState:atoi(NXGetDefaultValue(gameName, "Strict"))]; [idHighScore setIntValue:atoi(NXGetDefaultValue(gameName, "HighScore"))]; return self; } //-------------------------------------------------------------------------- // - saveStrictFlag: // // returns: (id) self // // The action for the Strict mode preference button. // //-------------------------------------------------------------------------- - saveStrictFlag:sender { char buffer[80]; sprintf(buffer, "%d", [idStrict state]); NXWriteDefault(gameName, "Strict", buffer); return self; } //-------------------------------------------------------------------------- // - setStrict: // // returns: (id) self // // Used to set the mode of the Strict mode preference button. // //-------------------------------------------------------------------------- - setStrict:(BOOL)flag { [idStrict setState:flag]; return self; } //-------------------------------------------------------------------------- // - strict // // returns: (BOOL) state // // Returns the current value of the Strict mode preference. // //-------------------------------------------------------------------------- -(BOOL) strict { return [idStrict state]; } //-------------------------------------------------------------------------- // - setHighScore: // // returns: (id) self // // Sets the high score textfield and saves the value in the defaults. // //-------------------------------------------------------------------------- - setHighScore:(int)score { char buffer[80]; if (score > [idHighScore intValue]) { sprintf(buffer, "%d", score); NXWriteDefault(gameName, "HighScore", buffer); [idHighScore setIntValue:score]; } return self; } //-------------------------------------------------------------------------- // - highScore // // returns: (int) score // // Returns the current high score value. // //-------------------------------------------------------------------------- -(int) highScore { return [idHighScore intValue]; } @end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.